This is a migrated thread and some comments may be shown as answers.

Layout Manager for WinForms

4 Answers 322 Views
Form
This is a migrated thread and some comments may be shown as answers.
JB
Top achievements
Rank 2
JB asked on 29 Jul 2008, 06:54 PM
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

4 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 01 Aug 2008, 09:35 AM
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.
0
Vinay
Top achievements
Rank 1
answered on 29 Aug 2008, 02:26 PM
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>.
0
Shamjith
Top achievements
Rank 1
answered on 13 Nov 2008, 02:00 PM
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.
0
Jack
Telerik team
answered on 14 Nov 2008, 05:08 PM
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.
Tags
Form
Asked by
JB
Top achievements
Rank 2
Answers by
Nikolay
Telerik team
Vinay
Top achievements
Rank 1
Shamjith
Top achievements
Rank 1
Jack
Telerik team
Share this question
or