Layout Manager for WinForms

5 posts, 0 answers
  1. JB
    JB avatar
    16 posts
    Member since:
    Jul 2008

    Posted 29 Jul 2008 Link to this post

    Hi,

    I'm new to RadControls so forgive me if it is a basic misunderstanding, The problem I'm having is understanding to how to layout my Windows Forms. I am dynamically adding RadControls Checkboxes to the RadPanel. However, after adding them, I see all of them next to each other and behind one another. I would like each of them to be in a new line. Please advice on how to achieve this.

    Regards,
    JB
  2. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 01 Aug 2008 Link to this post

    Hello Janahan,

    Thank you for this question.

    In order to show the controls properly, but not overlapping , you should set the Location for each of them. I have demonstrated how to layout a group of controls, where every control (except the first one) respects the location of the control before it and sets its Location accordingly.

    Alternatively, you can use the Microsoft FlowLayoutPanel with its FlowDirection set to TopDown. Just add the controls into it and they will be ordered appropriately.

    If you have additional questions, feel free to contact me.

    Regards,
    Nikolay
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Vinay
    Vinay avatar
    1 posts
    Member since:
    Aug 2008

    Posted 29 Aug 2008 Link to this post

    You can use a layout manager for it. Windows forms already have 2 of them, the flowlayoutPanel and TableLayoutPanel. However, for versatality, you need to use a professional layout manger e.g. <admin>link removed</admin>.
  5. Shamjith
    Shamjith avatar
    15 posts
    Member since:
    Sep 2008

    Posted 13 Nov 2008 Link to this post

    How to merge column in telerik winforms grid view? I have three data columns and two command columns. The header text of the command column should be "functions" and i need to merge these two cells into one. So in effect there should be four columns (Three columns to show data and one column to show two buttons). How to implement this? Also i am not able to access the sample application given above.
  6. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 14 Nov 2008 Link to this post

    Hi Shamjith,

    Thank you for this question.

    You have two options to solve this issue:

        1. You can use the new ColumnGroupsViewDefinition and add these columns to one column group. Consider the code snippet below:

    this.radGridView1.DataSource = table; 
     
    ColumnGroupsViewDefinition definition = new ColumnGroupsViewDefinition(); 
     
    definition.ColumnGroups.Add(new GridViewColumnGroup()); 
    definition.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow()); 
    definition.ColumnGroups[0].Rows[0].Columns.Add(this.radGridView1.Columns["ID"]); 
    definition.ColumnGroups[0].Rows[0].Columns.Add(this.radGridView1.Columns["Name"]); 
    definition.ColumnGroups[0].Rows[0].Columns.Add(this.radGridView1.Columns["Value"]); 
     
    definition.ColumnGroups.Add(new GridViewColumnGroup("Functions")); 
    definition.ColumnGroups[1].Rows.Add(new GridViewColumnGroupRow()); 
    definition.ColumnGroups[1].Rows[0].Columns.Add(this.radGridView1.Columns["Command1"]); 
    definition.ColumnGroups[1].Rows[0].Columns.Add(this.radGridView1.Columns["Command2"]); 
     
    this.radGridView1.ViewDefinition = definition; 
     


        2. The second option is to add two buttons in a custom cell. The following code snippet demonstrates this behavior:

    public class ButtonCell : GridDataCellElement 
        RadButtonElement button1; 
        RadButtonElement button2; 
     
        public ButtonCell(GridViewColumn column, GridRowElement row) 
            : base(column, row) 
        { 
        } 
     
        protected override Type ThemeEffectiveType 
        { 
            get 
            { 
                return typeof(GridCommandCellElement); 
            } 
        } 
     
        public RadButtonElement Button1 
        { 
            get 
            { 
                EnsureChildElements(); 
                return this.button1; 
            } 
        } 
     
        public RadButtonElement Button2 
        { 
            get 
            { 
                EnsureChildElements(); 
                return this.button2; 
            } 
        } 
     
        protected override void CreateChildElements() 
        { 
            base.CreateChildElements(); 
            button1 = new RadButtonElement("Edit"); 
            this.Children.Add(button1); 
            button2 = new RadButtonElement("Save"); 
            this.Children.Add(button2); 
        } 
     
        protected override SizeF ArrangeOverride(SizeF finalSize) 
        { 
            RectangleF clientRect = GetClientRectangle(finalSize); 
            if (this.Children.Count == 2) 
            { 
                this.Children[0].Arrange(new RectangleF(clientRect.Left, clientRect.Top, clientRect.Width / 2, clientRect.Height)); 
                this.Children[1].Arrange(new RectangleF(clientRect.Left + clientRect.Width / 2, clientRect.Top, clientRect.Width / 2, clientRect.Height)); 
            } 
            return finalSize; 
        } 


    I hope this helps. Do not hesitate to write us if you need further assistance.

    Best wishes,
    Jack
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top
UI for WinForms is Visual Studio 2017 Ready