Declined
Last Updated: 26 Jun 2020 15:26 by Al
Al
Created on: 20 Jun 2020 23:53
Category: UI for WinForms
Type: Feature Request
0
I would love to have the radbuttontextbox available as a grid column
I would love to have the radbuttontextbox available as a grid column
2 comments
Al
Posted on: 26 Jun 2020 15:26
thank you for the consideration and work around. 
ADMIN
Nadya | Tech Support Engineer
Posted on: 26 Jun 2020 10:17

Hello Al,

Thank you for sharing your ideas with us.

RadGridView does not have a button text box column out of the box but you can create it on your own. RadGridView provides a flexible mechanism for creating custom cell types with custom content elements. Please refer to the following article: Creating custom cells.

In order to achieve your goal, you can create a custom cell with RadButtonTextBoxElement in it and use this cell in the grid. Following the steps in the provided article I created a custom column in the grid that uses a custom cell with RadButtonTextBoxes:

 public partial class RadForm1 : Telerik.WinControls.UI.RadForm
 {
     public RadForm1()
     {
         InitializeComponent();
         RadButtonTextBoxColumn customColumn = new RadButtonTextBoxColumn("ButtonTextBoxColumn");
         this.radGridView1.Columns.Add(customColumn);
         this.radGridView1.Columns[0].Width = 200;
         for (int i = 1; i <= 10; i++)
         {
             this.radGridView1.Rows.Add("Item" + i);
         }

     }
 }

 public class ButtonTextBoxCell : GridDataCellElement
 {
     public ButtonTextBoxCell(GridViewColumn column, GridRowElement row) : base(column, row)
     {
     }

     private RadButtonTextBoxElement buttonTextBoxElement;
     protected override void CreateChildElements()
     {
         base.CreateChildElements();
         buttonTextBoxElement = new RadButtonTextBoxElement();
         RadButtonElement buttonElement = new RadButtonElement();
         RadButtonElement buttonElement2 = new RadButtonElement();
         buttonElement.Text = "Button1";
         buttonElement2.Text = "Button2";
         buttonTextBoxElement.RightButtonItems.Add(buttonElement);
         buttonTextBoxElement.RightButtonItems.Add(buttonElement2);
         this.Children.Add(buttonTextBoxElement);
     }


     protected override void SetContentCore(object value)
     {
         this.buttonTextBoxElement.Text = this.Value.ToString();
     }

     public override bool IsCompatible(GridViewColumn data, object context)
     {
         return data is RadButtonTextBoxColumn && context is GridDataRowElement;
     }
     protected override Type ThemeEffectiveType
     {
         get
         {
             return typeof(GridDataCellElement);
         }
     }
 }


 public class RadButtonTextBoxColumn : GridViewDataColumn
 {
     public RadButtonTextBoxColumn(string fieldName) : base(fieldName)
     {
     }

     public override Type GetCellType(GridViewRowInfo row)
     {
         if (row is GridViewDataRowInfo)
         {
             return typeof(ButtonTextBoxCell);
         }
         return base.GetCellType(row);
     }
 }

Note, since creating such custom RadButtonTextBoxColumn is currently achievable with the flexible mechanism that RadGridView offers I will set the feedback item status to declined.

I hope this helps. If you have any further question do not hesitate to contact me.

Regards,
Nadya
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.