We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Editing a Cell

When I click on a cell that is a Numeric Up Down it takes two clicks to change the value. I checked this by seeing if it is editing, using this.gridname.CurrentCell.IsEditing. Which doesn't switch to true until the second click. How do I get this to change so that when the cell is clicked once it changes the value.

Thanks again
-j

1 Reply

HA haneefm Syncfusion Team May 1, 2007 10:08 PM UTC

Hi John,

You can try this code snippet in CellButtonClicked event of the grid and let me know if this helps.

private void gridControl1_CellButtonClicked(object sender, GridCellButtonClickedEventArgs e)
{
GridControl grid = sender as GridControl;
if( !grid.CurrentCell.IsEditing )
{
grid.CurrentCell.MoveTo(e.RowIndex,e.ColIndex);
grid.CurrentCell.BeginEdit(true);
object cellText = grid.Model[e.RowIndex,e.ColIndex].CellValue ;
if( cellText != null && cellText.ToString() != string.Empty )
{
int i = int.Parse( cellText.ToString() );
if( e.ButtonIndex == 0 )///Up button
grid.Model[e.RowIndex,e.ColIndex].CellValue = i+1;
else//Down button
grid.Model[e.RowIndex,e.ColIndex].CellValue = i-1;
e.Cancel = true;
}
}
}

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon