Hello,
I'll try to describe my use case:
The Form1 contains an ultrawingrid that contains two colums:
- Flag (boolean)
- Text (string)
Into Form1 there is a registration on BeforeCheckStateChanged event (on "Flag" column editor, Infragistics.Win.CheckEditor). When this event occurs another form (Form2) is showed.
Form2 contains one UltraButton (button1). Clicking on "button1" causes the closure of the Form2.
Now if the user tries to change, using the Space key, the checkstate for a row ("Flag" column) into Form1 grid, the Form2 appears and disappears (i think this is a bug) immediately because the "button1" click event is fired unnecessarily.
This behavior doesn't happen when the user changes the checkstate via mouse click on "Flag" column cell.
I've attached a sample project that shows the bug.
I'm using the version 2010.1.2105 (it means 2010.1 + HotFix n. 2105).
I've reproduced the same behavior with the trial version of 2011.2.
Thanks in advance.
Hi,
The problem here is that the event is firing on the KeyDown event and so the KeyUp gets triggered on the new dialog you showed and it is being handled by the control with focus at the time, which is the button (since it's the only control on form2).
Also, this has nothing to do with the problem you are having, but it's really not a good idea to hook into events on the column's editor. If you want to trap when the user changes the CheckBox, then you should use the CellChange event of the grid.
To avoid the KeyUp problem, I tried launching the dialog via a BeginInvoke instead of doing it directly inside the event. That way all of the keyboard processing completes before the dialog is displayed.But it does not work. I think this might be because there is another timing issue going on here with yuor handling of the grid's KeyDown event to put the cell into edit mode.
If you tell me what you are trying to achieve, exactly, then perhaps I could help you achieve it. But right now, it's a bit unclear. It looks like you don't want anything in the grid to be editable and you are just using the to select a list of rows using the checkbox column. So all you really want is for the spacebar to toggle the checkbox and show a dialog. If that's the case, then I think it makes more sense to simply toggle the checkbox in the KeyUp event of the grid rather than putting the cell into edit mode in KeyDown.
private void ultraGrid1_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Space) { if (ultraGrid1.ActiveRow != null) { this.ultraGrid1.ActiveRow.Cells["Flag"].Value = !((bool)this.ultraGrid1.ActiveRow.Cells["Flag"].Value); this.ShowForm2(); } } } private void ShowForm2() { using (var form2 = new Form2()) { form2.ShowDialog(); } }
Thanks for your reply,
in my real use case, when the checkbox cell is active and the user presses the space button (or clicks with the mouse button), i have to execute some validations and if the validations fail i've to show to the user a Confirm Boolean Operation Dialog (e.g.: "are you sure to continue with this operation? YES NO").
I've done this in BeforeCheckStateChangedEvent because for me it was a right idea to apply the validation (and ask confirmation to the user) before the checkstate was changed.
I've just tried to show the Form2 on CellChange event, as you suggested, but the behavior remains the same.
I've also tried to replace into Form2 the UltraButton with a standard .Net Button and the problem doesn't show up.
I hope now my use case is more clear :)
Thanks again