开发者

get all control names of a form in another form

开发者 https://www.devze.com 2023-04-12 00:11 出处:网络
I have two forms that are called Customers and CustomerControlList In Customers Form, I have DevExpress Layout Controls like TabbedCon开发者_如何学PythontrolGroup, LayoutControlGroup, LayoutItem and i

I have two forms that are called Customers and CustomerControlList In Customers Form, I have DevExpress Layout Controls like TabbedCon开发者_如何学PythontrolGroup, 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);
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消