Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6121243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:45:44+00:00 2026-05-23T15:45:44+00:00

NOTE: All controls described in this question are DEVEXPRESS controls. I am attempting to

  • 0

NOTE: All controls described in this question are DEVEXPRESS controls.
I am attempting to programatically add both LayoutControlItems and EmptySpaceItems to a LayoutControlGroup on a DevExpress LayoutControl.

The requirements for my project require that I have a LayoutControlGroup panel that is dependent on a set of filter items chosen from another control on the layout control. If there are no filters chosen, than none of the `LayoutControlItems are shown. If one or more of the filters are chosen that I add one or more of the controls to the group based on the selection.

The way that I attempt to do this is the following:

1) in the designer for the LayoutControl I have already created the LayoutControlGroup with the LayoutControlItems. There are 6 total, and each LayoutControlItem contains a PanelControl that contains a ListBoxControl

2) When the form is initalized I hide each of the LayoutControlItems from the LayoutControlGroup using the LayoutControlItem.HideFromCustomization() method.

3) After the user selects a filter or set of filters I run the following code attempting to restore the control items to the group from left to right.

this.layoutGroupScenarioPortfolios.BeginUpdate();

LayoutControlItem layoutControlToAdd;
LayoutControlItem lastLayoutControlItem = null;

for (int loop = 0; loop < selectedFilters.Length; loop++)
{
     layoutControlToAdd = LayoutControlItemFactoryUtil(selectedFilters[loop]);

     if (layoutControlToAdd == null)
     {
          continue;
     }

     if (loop < 1)
     {
     layoutControlToAdd.RestoreFromCustomization(this.layoutControlGroupSelectedFilters);
     }
     else
     {
          layoutControlToAdd.RestoreFromCustomization(lastLayoutControlItem, DevExpress.XtraLayout.Utils.InsertType.Right);
     }

     lastLayoutControlItem = layoutControlToAdd;
 }

 for (int loop = 0; loop < numOfEmptySpaceItemsNeeded; loop++)
 {
      layoutControlToAdd = new EmptySpaceItem(this.layoutControlGroupSelectedFilters)
      {
           Owner = this.layoutControlGroupSelectedFilters.Owner
      };

      layoutControlToAdd.RestoreFromCustomization(lastLayoutControlItem, DevExpress.XtraLayout.Utils.InsertType.Right);
      lastLayoutControlItem = layoutControlToAdd;
 }

 this.layoutControlGroupSelectedFilters.TextVisible = true;
 this.layoutGroupScenarioPortfolios.EndUpdate();

As you can see from the code one loop adds the appropriate ListControlBox to the group. The second loop tries to add empty space items to make sure that the list box control does not take up the entire group. By the end of this code there should be 6 items spanning the group control, each with the same width in the control.

The problem is that the first control added takes up half of the group box’s space while the other 5 items are equally fitted into the remaining half of the group box.

In the first loop, is the RestoreFromCustomization() method with one parameter the correct method to use?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:45:44+00:00Added an answer on May 23, 2026 at 3:45 pm

    I would suggest to place the controls at runtime. LayoutControl will manage the LayoutControlGroups and EmptySpaceItems.

    Here is the code I had written to place user controls into the LayoutControl at runtime:

    LayoutControlItem lastItem = null;
    int RowWidth = 0;
    
        public void AddMyControl()
                {
                    MyControl myControl = new MyControl("");
                    myControl.Name = Guid.NewGuid().ToString();
    
                    LayoutControlItem item = new LayoutControlItem();
                    item.Name = Guid.NewGuid().ToString();
                    item.Text = "";
    
                    MyLayoutControl.BeginUpdate();
                    //We need to determine where to insert the new item. Right or Below. If there is  
                    //space on the right we insert at Right else we just add the item.
                    if(lastItem == null || lastItem != null && (MyLayoutControl.Width - UserControlWidth) < RowWidth)
                    {
                        MyLayoutControl.AddItem(item);
                        RowWidth = item.MinSize.Width;
                    }
                    else
                    {
                        MyLayoutControl.AddItem(item, lastItem, DevExpress.XtraLayout.Utils.InsertType.Right);
                    }
                    item.Control = myControl;
                    RowWidth += item.MinSize.Width;
                    lastItem = item;
                    item.Name = " ";
                    MyLayoutControl.BestFit();
                    MyLayoutControl.EndUpdate();
                }
    

    If you just need left to right controls, flowlayoutpanel will suit better. Sometimes LayoutControl is tough to work with. I had eventually go with flowlayoutpanel as it is much simpler to work with.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My table is like this on Postgres, note that all days start by 01,
Note: Originally this question was asked for PostgreSQL, however, the answer applies to almost
Please note this is a question with regard to Backbone.js. This is not a
We all know that having a good note taking tool is important as a
NOTE: Using .NET 2.0, and VS2005 as IDE Hello all, I'm working on logging
Note: Using Monotouch. I have a directory called Images where I have all my
How can I replace CHAR with VARCHAR2 in all tables in a schema? Note:
NOTE: XMLIgnore is NOT the answer! OK, so following on from my question on
Note: This was posted when I was starting out C#. With 2014 knowledge, I
Note: By workflow i'm not referring to workflow technology, such as Workflow foundation. All

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.