When user clicks on a grid header and presses the Delete key, I need to intercept that key press:
* If (selected) row is one that should not be deleted, terminate processing the delete key.
* else allow built-in Infragistics grid row delete processing to handle deleting the row.
Being new to Infragistics, I'm not sure:
1) how to set-up intercepting the Delete key press. I tried select the grid in VisualStudio in the designer and entered the name of a KeyUp handing routine, but it isn't invoked. Do I need to select something else? I tried entering names for KeyDown and KeyPress, but now I'm getting the error regarding 'MdiChildFormBase_Fill_Panel' - see below.
2) How do I: * Terminate Delete processing? * Allow Infratistics built-in processing to actually delete the row?
ALSO, how do I prevent the VS error "The variable 'MdiChildFormBase_Fill_Panel' is either undeclared or was never assigned. ". I get this fairly frequently. The designer generated 'MdiChildFormBase_Fill_Panel'. When VS complains about this, it no longer displays the design view. I'm using VS 2012 and Infragistics 2010.3. I know there's a 2012.1 version, but my department is using 2010.
Thanks,
Daryl
Restarting VS2010 resolved my designer error. I added handlers for both KeyDown & KeyPress. When I run the application the KeyDown handler does get invoked.
In my handler so far I just have local copies of the arguments so I can see what's available for determining if selected row is one that can be deleted or not. WhenI let execution continue, it did invoke the Infragistics Delete handler - the "do you want to delete this row" popup dialog displayed briefly displayed, then disappeared without getting a button click from me, and application became unresponsive. The VS debugger isn't waiting on input from me.
Daryl,
Rather than handling the key events of the grid it would be simpler to handle the BeforeRowsDeleted event and cancel it if the rows being deleted are not able to be deleted. The event exposes the Rows that will be deleted in the event args so that you can check if the row(s) are ones that can be deleted.
Let me know if you have any questions with this matter.
It would help to see the code for the form to get a better idea of what might have caused the warning and what is the best way to address it.
Alan,
Here are 2 small snippets generated by the VS2010 designer...
// // MdiChildFormBase_Fill_Panel // this.MdiChildFormBase_Fill_Panel.Location = new System.Drawing.Point(0, 84);this.MdiChildFormBase_Fill_Panel.Size = new System.Drawing.Size(992, 632);
...
this.Controls.SetChildIndex(this._ChildMdiFormBase_Toolbars_Dock_Area_Left, 0);this.Controls.SetChildIndex(this.MdiChildFormBase_Fill_Panel, 0); // <--- This is the culpritthis.Controls.SetChildIndex(this.schedTemplPanel, 0);
Is MdiChildFormBase_Fill_Panel a property of this form or is it a property of a form that is being used as the base class? Also can you see a line setting this.MdiChildFormBase_Fill_Panel to a value before the line that causes the error?
Regarding the deletion of rows, you would likely be better off using just the BeforeRowsDeleted event and adding additional logic there. If you do need to use the Key events, then you would have to track if you want to cancel the BeforeRowsDeleted in a flag that you store on the form and still need to put logic there or you would need to change the KeyActionMappings of the grid so that Delete doesn't do anything and then in your key event handle if you are going to delete the row or not.
If you wish to change the KeyActionMappings you would need to remove the mapping for the delete key from the collection to change the behavior of the grid. If you do this, for the rows that you wish to delete, you would need to call UltraGrid.PerformAction passing in UltraGridAction.DeleteRows for the action.
My co-workers agree that BeforeRowsDeleted is the correct place to handle. Thanks for your kind, helpful assistance. I especially appreciate the links to relevant areas of documentation.
Your tips & pointers have been most helpful!
Thanks,Daryl