Rev
Rev

Reputation: 2275

Adding all items in Available-Item Section to Devexpress Layout Control?

I try using Devexpress Layout-Control (For costume usage). So I want add all item's exist in Available-Item Section to Layout-Control root as Layout-Item via code .

So it must be possible, But How? (I don't know, any solution ;)

Edit 1 sorry For less information at first time

Let me explain What I do in My example, I Use code to create one or more Control in Layout-Control at Form-Loaded Event.

After that in one Button_Click, I Use :

 Layout1.WriteToXML(XmlWriter_Object);

to save Layout Current View. These step work well! if I want recover that view at next step with this command :

 Layout1.ReadFromXML(XmlReader_Object);

As Result I got all item's(which created via code) in Available-Item Section! So this is My problem!

Why These Happend?

Ps: Both XmlReader_Object and XmlWriter_Object refer same file on machin.

Upvotes: 1

Views: 3011

Answers (1)

DmitryG
DmitryG

Reputation: 17848

To move an item from the Available Items list onto the LayoutControl, do the following.

1) Remove the item from the LayoutControl.AvailableItems collection:

layoutControl1.AvailableItems.Remove(item1);

2) Add this item to the layout. For instance, you can use the following code to append the item to a group:

layoutGroup1.Children.Add(item1);

Update on Edit1:

When creating layout items dynamically(in code), it is necessary to register their identifiera(names) using the RegisterName method. The code can look as follows:

LayoutItem layoutItem1 = new LayoutItem()
{
    Name = "Item1",
    Label = "Item1",
    Content = new Button()
    {
        Content = "Button"
    }
};
RegisterName(layoutItem1.Name, layoutItem1);
layoutGroup1.Children.Add(layoutItem1);

This way, everything should work as expected.

Upvotes: 7

Related Questions