Category / Section
How to use a PushButton in a cell of WinForms GridControl ?
1 min read
Push button cell type
In GridControl, you can set the CellType property to PushButton and the button is handled by using the grid’s CellButtonClicked event.
C#
//set the celltype into pushbutton this.gridControl1[3, 3].CellType = "PushButton"; this.gridControl1[3, 3].Description = "Push Me"; //the pushbutton is handled using the CellButtonClicked event. void gridControl1_CellButtonClicked(object sender, Syncfusion.Windows.Forms.Grid.GridCellButtonClickedEventArgs e) { string s = string.Format("You Clicked ({0},{1})cell", e.RowIndex, e.ColIndex); MessageBox.Show(s); }
VB
'set the celltype into pushbutton Me.gridControl1(3, 3).CellType = "PushButton" Me.gridControl1(3, 3).Description = "Push Me" 'the pushbutton is handled using the CellButtonClicked event. Private Sub gridControl1_CellButtonClicked(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridCellButtonClickedEventArgs) Dim s As String = String.Format("You Clicked ({0},{1})cell", e.RowIndex, e.ColIndex) MessageBox.Show(s) End Sub
The following screenshot displays the PushButton added into the cell.
Figure 1: The PushButton is added into the cell
Note:
The pushbutton is also handled by using PushButtonClicked Event.
Samples:
C#: PushButton_Cell
VB: PushButton_Cell
Reference link: https://help.syncfusion.com/windowsforms/grid-control/cell-types#pushbutton-cell-type