简体   繁体   中英

get all control names of a form in another form

I have two forms that are called Customers and CustomerControlList In Customers Form, I have DevExpress Layout Controls like TabbedControlGroup, LayoutControlGroup, LayoutItem and in those LayoutItems I use any control like TextEdit, ComboEdit, etc...

And I want to get all control names which is TextEdit, etc... in CustomerControlList so how can I do that? I can not iterate through these layout controls...

For Example: I get instance of form like and loop through

frmCustomer fc= new frmCustomer();

foreach(Control c in fc.Controls)
{

}

this doesn't work, Only comes Windows.Forms.Collection so it comes zero as control count.

Also is that possible to get dynamically created controls' names in another form? if so, how to do that?

Thanks!

this worked for me (this is almost a straight rip from my code):

TextEdit devXtextControl;

foreach (Control control in this.Controls[0].Controls)
{
    if ((devXtextControl = control as TextEdit) != null)
    {
        // do something with devXtextControl
        Messagebox.Show(devXtextControl.Name);
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM