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

Multiple Control in Single GridViewColumn

3 Answers 249 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bibek
Top achievements
Rank 1
Bibek asked on 25 Feb 2009, 06:04 PM
Hi,

Can we have multiple control for example TextBox and Button in the same column ?

What I really want is : In the RadGridView one column consists of some file path..so I want the textpath and button in the same column so that the user can click on that button to browse and change the file path.

thanks in advance.


regards,

Bibek Dawadi

3 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 26 Feb 2009, 09:59 AM
Hello Bibek,

Yes, this is possible. You should process the CellFormatting event. Please check the following KB article. You should also set the ReadOnly property of RadGridView to true.

Should you have any further questions, please write us.

Regards,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Bibek
Top achievements
Rank 1
answered on 09 Mar 2009, 05:44 PM
Hi,

I would like to have button inside a cell just like in property grid, Can you send me some samples

Thanks in advance.

regards,

Bibek
0
Jack
Telerik team
answered on 12 Mar 2009, 03:34 PM
Hi Bibek,

Thank you for this question.

You should create a custom cell and add a RadButtonElement inside. Check the following code snippet:

void radGridView1_CreateCell(object sender, GridViewCreateCellEventArgs e) 
    if (e.Row is GridDataRowElement && e.Column.HeaderText == "Name"
    { 
        e.CellElement = new MyCell(e.Column, e.Row); 
    } 
 
public class MyCell : GridDataCellElement 
    RadButtonElement button; 
 
    public MyCell(GridViewColumn column, GridRowElement row) 
        : base(column, row) 
    { 
    } 
 
    protected override void CreateChildElements() 
    { 
        button = new RadButtonElement(); 
        button.Text = "..."
        button.Click += new EventHandler(button_Click); 
        this.Children.Add(button); 
    } 
 
    void button_Click(object sender, EventArgs e) 
    { 
        MessageBox.Show("I was clicked!"); 
    } 
 
    protected override SizeF ArrangeOverride(SizeF finalSize) 
    { 
        SizeF size = base.ArrangeOverride(finalSize); 
        RectangleF clientRect = GetClientRectangle(finalSize); 
        foreach (RadElement element in this.Children) 
        { 
            if (element == button) 
            { 
                button.Arrange(new RectangleF( 
                    Math.Max(2, clientRect.Right - 22), 
                    clientRect.Top + 2, 
                    Math.Min(clientRect.Width, 20), 
                    clientRect.Height - 4)); 
            } 
            else if (element is IInputEditor) 
            { 
                element.Arrange(new RectangleF( 
                    clientRect.Left, clientRect.Top, 
                    Math.Max(0, clientRect.Width - 28), 
                    clientRect.Height)); 
            } 
        } 
        return size; 
    } 
 

I hope this helps. If you have any questions, don't hesitate to ask.

Regards,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Bibek
Top achievements
Rank 1
Answers by
Jack
Telerik team
Bibek
Top achievements
Rank 1
Share this question
or