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
Alan,
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
Daryl,
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.
Let me know if you have any questions with this matter.
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?
FYI ... the BeforeRowsDeleted event handler is already being used for some other purpose. I believe(?) I need to just handle the Delete key specifically.
I did figure out the code in my original KeyDown handler for checking if the row should be deleted or not. Are there similar items in Key handling to the BeforeRowsDeleted?* e.DisplayPromptMsg = false* e.Cancel = true
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);