Click here to Skip to main content
15,909,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i want find checkboxX control in supertabcontrolpanel1 in supertabitem1 in supertabcontrol1

C#
foreach (Control con1 in Controls["superTabControl1"].Controls)
           {
               try
               {
                   foreach (Control con2 in con1.Controls["superTabItem1"].Controls)
                   {
                       foreach (Control con3 in con2.Controls["superTabControlPanel1"].Controls)
                       {
                           bool dd = ((CheckBoxX)con3).Checked;//it is checkboxX (dotnetbar componenets)
                       }
                   }
               }
               catch (Exception)
               {
               }
           }


how do i
Posted
Comments
OriginalGriff 22-Feb-14 4:50am    
And?
What is the problem you are meeting?
What does this do that you don't expect, or do that you don't?
Please remember that we can't see your screen, access your HDD, or read your mind - so we have no idea what your various controls do contain, and can't check your code by running it.
We need to know what is going on if we are to help you!

1 solution

Personally I would set it up a bit more generic, i.e. a recursive method.

C#
public Control FindControlRecursive(Control control, string id)
{
    if (control == null) throw new ArgumentNullException("control");
    if (control.ID == id) return control;
    
    foreach (Control child in control.Controls)
    {
        Control c = FindControlRecursive(child, id);
        if (c != null) return c;
    }
    
    return null;
}


And then you can call it like this
C#
CheckBox chkbx = (CheckBox)FindControlRecursive(superTabControl1, "idofcheckbox")
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900