Question

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?

Was it helpful?

Solution

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
}

OTHER TIPS

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
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top