Multiple Control in Single GridViewColumn

4 posts, 0 answers
  1. Bibek
    Bibek avatar
    7 posts
    Member since:
    Dec 2008

    Posted 25 Feb 2009 Link to this post

    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
  2. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 26 Feb 2009 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Bibek
    Bibek avatar
    7 posts
    Member since:
    Dec 2008

    Posted 09 Mar 2009 Link to this post

    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
  5. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 12 Mar 2009 Link to this post

    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.
Back to Top