I am using devexpress layout control. When I add a text box to the layout a new 'layout control item' will be created and the text of the layout control item will be used as the label of the text box. (see pic) If I know the name of the layout control item I can find out the control in that. But how I can find the layout control item of a text box?

有帮助吗?

解决方案

The LayoutControl.GetItemByControl method returns the layout item contained within the root group which holds the specified control:

LayoutControlItem itemForTextBox = layoutControl1.GetItemByControl(textBox);
if(itemForTextBox != null) { 
    // do something
}

其他提示

You can focus the textbox in designer and press esc. Then the LayoutControlItem is focused. You can name it and get access via name in quellcode.

If you want to get access to layoutcontrolitem without using designer you can try this:

foreach (Component com in textbox.Container.Components)
{
    if (com is LayoutControlItem)
    {
        //Do Something
    }
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top