Category / Section
How to get the cell value in WinForms GridGroupingControl?
1 min read
Editing the cell value
The final edited value of a cell can be obtained from GridCurrentCell Renderer by using the TableControlCurrentCellValidated event and the TableControlCurrentCellKeyDown event when Enter key is pressed.
C#
// This event is fired when the current cell is validated, i.e., when editing is completed.
this.gridGroupingControl1.TableControlCurrentCellValidated += new Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlEventHandler(gridGroupingControl1_TableControlCurrentCellValidated);
// This event is fired when a key is pressed.
this.gridGroupingControl1.TableControl.CurrentCellKeyDown += new KeyEventHandler(TableControl_CurrentCellKeyDown);
// Used to store grid current cell value.
GridCurrentCell cc;
// Used to store the cell value.
string cellvalue;
void gridGroupingControl1_TableControlCurrentCellValidated(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlEventArgs e)
{
cc = e.TableControl.CurrentCell;
cellvalue = cc.Renderer.GetCellValue().ToString();
}
void TableControl_CurrentCellKeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode.Equals(Keys.Enter))
this.textBox1.Text = cellvalue;
else
this.textBox1.Text = string.Empty;
}
VB
'This event is fired when the current cell is validated, i.e., when editing is completed.
AddHandler Me.gridGroupingControl1.TableControlCurrentCellValidated, AddressOf gridGroupingControl1_TableControlCurrentCellValidated
'This event is fired when a key is pressed.
AddHandler Me.gridGroupingControl1.TableControl.CurrentCellKeyDown, AddressOf TableControl_CurrentCellKeyDown
'Used to store grid current cell value.
Dim cc As GridCurrentCell
'Used to store the cell value.
Dim cellvalue As String
Private Sub gridGroupingControl1_TableControlCurrentCellValidated(sender As Object, e As Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlEventArgs)
cc = e.TableControl.CurrentCell
cellvalue = cc.Renderer.GetCellValue().ToString()
End Sub
Private Sub TableControl_CurrentCellKeyDown(sender As Object, e As KeyEventArgs)
If e.KeyCode.Equals(Keys.Enter) Then
Me.textBox1.Text = cellvalue
Else
Me.textBox1.Text = String.Empty
End If
End Sub