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!
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).
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.
Hello,
What you would do is to create a bool flag which detemine if you are over an UltraGrid or not and based on that to decide what to do in the BeforeExitEditMode of the UltraGrid like the following:
private void ultraGrid1_BeforeExitEditMode(object sender, Infragistics.Win.UltraWinGrid.BeforeExitEditModeEventArgs e) { if (notOverGrid) {
//Do what you need here when you are clicking outside the UltraGrid.
} }
private void ultraGrid1_MouseEnter(object sender, EventArgs e) { notOverGrid = false; }
private void ultraGrid1_MouseLeave(object sender, EventArgs e) { notOverGrid = true; }
Please let me know if that is not what you are looking for.
Thanks Danko!
Yes, this would've been a great solution. The only problem is that it also occurs when I click outside the grid.
Can I somehow determine if the second click was on a cell or outside the grid ?
It seems to me that you are able to use the BeforeExitEditMode event of the UltraGrid. First you click some cell which enters in edit mode, and then you click on the next cell for example. The BeforeExitEditMode event will fire and you would check for your conditions and if you need cancel the event.
Please let me know if I can assist you further.
Thanks for your answers!
Basically, the feature I'm trying to accomplish is the following :
I click on a cell, and then click another one - but i want to cancel the second event and let the first one active when some conditions are fullfilled.
If I use the BeforeSelectChange event - it doesn't trigger. I f I use BeforeCellActivates - it triggers, but I can't work with it - it isn't cancelable.
I am not sure I understand your question. You mean that you have selected row and in the same time you have a cell in edit mode? I think that when you have a cell into edit mode you are talking about the active row instead of the selected?
Please let me know what I misunderstand in your sceanario.