Hi all,
I want to loop thru the Controls.Controls collection to find a listbox
located within the 3rd tabpage of a tabcontrol on my windows form.
I've written this code, but I don't want to hard-code the tabpage index. I
want the code to be able to search thru all the tabpages for the listbox. So
far the line "tabCtl1.Controls" only captures the
TabControl.ControlCollection on TabPages[n].
private void test(string mode)
{
foreach (Control lb_control in this.tabCtl1.Controls)
{
string ctrlName = String.Format("lb{0}2", mode);
if (lb_control.GetType().Assembly.GetName().Name == "ListBox")
{
if (lb_control.Name == ctrlName)
{
txtDHValues.Text = "";
return;
}
}
}
}
Thanks in advance.
regards,
Andrew