Hi!
I need to cancel the selection of a new row, and set the selected to the previously selected one : e.g. row nr 1 is selected, and the user clicks on the third one - I want to display a message and the selection to remain on the first one. Ho can I implement this - I've tried using the BeforeCellActivate event, and cenceling it, but it doesn't work.
Any ideas ?
Thanks!
Hi Marius,
Clicking on a cell either enters edit mode on the cell or selects something (the cell or the row). It cannot do both, because the grid will not allow you to have a cell in edit mode and also have selected cells or rows at the same time. The two states are mutually exclusive.
Either way, clicking on a cell will activate the cell and the row, but active is not the same as selected. There can be only one active row and only one active cell in the grid at any one time, but there can be multiple selected rows/cells.
If you set CellClickAction to RowSelect, you could still edit a cell, but you have to click on the cell and then enter edit mode in some other way. I may be wrong, but I think pressing F2 will enter edit mode on a cell by default. This is what Excel does.
If I am wrong about that, then you could implement it that way easily enough by trapping for the F2 key or trapping for a double-click on the cell, or some other UI interaction and then calling grid.PerformAction(EnterEditMode).
Any ideas on this?
Thanks Brian!
I still get a weird behaviour : If I don't set the CellClickAction to Select, the event doesn't trigger ?! If I do this, I loose a feature - editing cells content ...
Why doesn't the clicking of a cell automatically change the selected row/cell ?
Marius.
The event is BeforeSelectChange. When rows are selected the e.Selected.Rows property will return the selection as it will be if the event is not canceled (the event is cancelable).