Clear textbox problem
-
Dear all, I wrote this piece of code to clear all the textboxes on a control all at once.
foreach (Control control in tabpage.Controls) { if (control.GetType() == typeof(TextBox)); { control.Text = ""; } }
It works , but .. it also clears all the labels in the control ; however labels are not of type Textbox. Could somebody tell me what I am doing wrong ? kind regards, -
Dear all, I wrote this piece of code to clear all the textboxes on a control all at once.
foreach (Control control in tabpage.Controls) { if (control.GetType() == typeof(TextBox)); { control.Text = ""; } }
It works , but .. it also clears all the labels in the control ; however labels are not of type Textbox. Could somebody tell me what I am doing wrong ? kind regards,Addition to the previous post ... this works :
for (int i = 0; i < this.Controls.Count; i++ ) { if (this.Controls[i] is TextBox) { this.Controls[i].Text = ""; } }
I'm puzzled now :confused: -
Addition to the previous post ... this works :
for (int i = 0; i < this.Controls.Count; i++ ) { if (this.Controls[i] is TextBox) { this.Controls[i].Text = ""; } }
I'm puzzled now :confused: -
Dear all, I wrote this piece of code to clear all the textboxes on a control all at once.
foreach (Control control in tabpage.Controls) { if (control.GetType() == typeof(TextBox)); { control.Text = ""; } }
It works , but .. it also clears all the labels in the control ; however labels are not of type Textbox. Could somebody tell me what I am doing wrong ? kind regards,