Articles in this section
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 fires when currentcell is validated, that is, 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 currentcell is validated, that is, when editing is completed.
Private Me.gridGroupingControl1.TableControlCurrentCellValidated += New Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlEventHandler(AddressOf gridGroupingControl1_TableControlCurrentCellValidated)
'This event is fired when a key is pressed.
Private Me.gridGroupingControl1.TableControl.CurrentCellKeyDown += New KeyEventHandler(AddressOf TableControl_CurrentCellKeyDown)
'Used to store grid current cell value.
Private cc As GridCurrentCell
 Used to store the cell value.
Private cellvalue As String
Private Sub gridGroupingControl1_TableControlCurrentCellValidated(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlEventArgs)
   cc = e.TableControl.CurrentCell
   cellvalue = cc.Renderer.GetCellValue().ToString()
End Sub
Private Sub TableControl_CurrentCellKeyDown(ByVal sender As Object, ByVal e As KeyEventArgs)
   If e.KeyCode.Equals(Keys.Enter) Then
      Me.textBox1.Text = cellvalue
   Else
      Me.textBox1.Text = String.Empty
   End If
End Sub

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied