this.gridDesktop.CellDataChanged -= new Aspose.Grid.Desktop.CellEventHandler(this.gridDesktop_CellDataChanged);
e.Cell.Value=e.Argument;
this.gridDesktop.CellDataChanged += new Aspose.Grid.Desktop.CellEventHandler(this.gridDesktop_CellDataChanged);
}
It works in all cases with exception for case when u try to clear cell - grid allows this operation for some reason
I debugged the code and found, that it fires the event 2(!) times when we clear the cell (instead of one time for any other op) and for some reason it works not correctly (or maybe I've missed the point).
I've told Nick.Liu 'bout these strange 2 times fired event, but it seemed to him then that everythin' is ok .
Style class provides CellLocked property to prevent user from inputing anything. You can set the style to a range of cells, rows or a columns. If you don't want user input anything in a worksheet, you can set Protected property equal true. Example:
First, in Form_Load event handler, set "aaaaa" string value to "b2" cell:
this.gridDesktop.CellDataChanged -= new Aspose.Grid.Desktop.CellEventHandler(this.gridDesktop_CellDataChanged); gridDesktop.Worksheets[0].Cells["b2"].Value = "aaaaa"; this.gridDesktop.CellDataChanged += new Aspose.Grid.Desktop.CellEventHandler(this.gridDesktop_CellDataChanged);
Second, in CellDateChanged event handler, prevent any changes:
this.gridDesktop.CellDataChanged -= new Aspose.Grid.Desktop.CellEventHandler(this.gridDesktop_CellDataChanged); e.Cell.Value=e.Argument; this.gridDesktop.CellDataChanged += new Aspose.Grid.Desktop.CellEventHandler(this.gridDesktop_CellDataChanged);
Finally, run, and use context menu in "b2" cell, select "Clear Contents" command. but "aaaaa" is still in the cell. It's right.