ButtonEdit GridControl cell type
Thanks for contacting Syncfusion Support.
To have a combination of ComboBox and the ButtonEdit cell within a single Grid cell, create a custom cell model and renderer which is derived from the ComboBoxCellModel and renderer. Please refer to the following code example,
Code Example:
//Custom cellModel and Renderer
class ComboCellModel : GridComboBoxCellModel
{
public ComboCellModel(GridModel grid)
: base(grid)
{
//Set the size of the button bar.
ButtonBarSize = new System.Drawing.Size(30, 15);
}
public override GridCellRendererBase CreateRenderer(GridControlBase control)
{
return new ComboCellRenderer(control, this);
}
}
class ComboCellRenderer : GridComboBoxCellRenderer
{
GridCellButton button;
public ComboCellRenderer(GridControlBase control, GridCellModelBase model)
: base(control, model)
{
button = new GridCellButton(this);
//Add the button to the comboBox cell
this.AddButton(button);
}
}
//In FormLoad
//Register the custom CellModel
this.gridControl1.Model.CellModels.Add("ComboBoxButtonEditCell", new ComboCellModel(this.gridControl1.Model));
//Setting the CellType
this.gridControl1[2, 3].CellType = "ComboBoxButtonEditCell";
Sample: http://www.syncfusion.com/downloads/support/forum/120486/ze/CS1040098417
Also, refer to the following dashboard sample, which shows how to have the custom cell types in the GridControl.
Dashboard Sample Location:
<InstalledLocation>\Syncfusion\EssentialStudio\<VersionNo>\Windows\Grid.Windows\Samples\Custom Cell Types\Interactive Cell Demo\CS
Regards,
Adhi
Thanks for your update.
It is working properly when we have invoked the button_Clicked event through the renderer. Please refer to the following code example,
Code Example:
//Get the ComboCellRenderer
ComboCellRenderer renderer = gridControl1.GetCellRenderer(2, 3) as ComboCellRenderer;
//Invoke the button clicked event
renderer.button.Clicked += button_Clicked;
void button_Clicked(object sender, GridCellEventArgs e)
{
MessageBox.Show(String.Format("Pressed Button at ({0},{1})", e.RowIndex, e.ColIndex));
}
Sample: http://www.syncfusion.com/downloads/support/forum/120486/ze/ButtonClicked409237133
Regards,
Adhi
- 3 Replies
- 2 Participants
-
TT tttmack
- Sep 20, 2015 05:20 PM UTC
- Sep 23, 2015 11:27 AM UTC