Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
4032
UltraWinGrid: How capture DEL-key on active cell
posted

I have a ultrawingrid bound to ultradatasource (version 2020.1)

The grid is multiband (depth 2). In band1 users can go into edit mode pressing digit or letter key. Edit Mode is startet in KeyPress-Event if pressed key is digit or letter.

Problem: If user press DEL-Key, the cell text of the active cell gets deleted. How I can trap the DEL-Key? If cell-text is deleted I should do some depending action in related data.

I have tried KeyDown, KeyPress, BeforeCellUpdate, AfterCellUpdate but none of these events gets raised.

Grid InitializeLayout:

e.Layout.Override.AllowAddNew = AllowAddNew.No;
e.Layout.Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.False;
e.Layout.Override.AllowDelete = Infragistics.Win.DefaultableBoolean.False;

e.Layout.Override.SelectTypeCol = SelectType.None;
e.Layout.Override.SelectTypeRow = SelectType.None;
e.Layout.Override.SelectTypeCell = SelectType.None;

e.Layout.Override.CellClickAction = CellClickAction.CellSelect;
e.Layout.Override.HeaderClickAction = HeaderClickAction.Select;

Band 1

band1.Override.CellMultiLine = DefaultableBoolean.True;

band1.Override.SelectTypeCell = SelectType.Extended;

any ideas how to capture the DEL-Key?

  • 2700
    Offline posted

    Hello Markus,

    Thank you for posting to Infragistics Community.

    I have been looking into your question and created a small sample with an UltraGrid using version 20.1. On my side everything works as expected and the events you mention are properly raised for the grid. 

    However, I determined that the KeyPress event is not raised when pressing the “Delete” key. The KeyDown/KeyUp events are, though. This is valid for most controls, since the KeyPress event sends a character to the control based upon the character-key you press and the “Delete” key does not represent a character.

    Additionally, in the sample the grid’s layout override properties are set as per your snippet. However, with these settings only I cannot observe the behavior, where the active cell’s value is being deleted on “Del” key press. I am wondering if it is possible that there are some other properties set for the grid through the designer? Anyways, the same behavior can easily be achieved by handling the grid’s KeyDown event and checking the e.KeyKode to equal Keys.Delete. If the grid’s ActiveCell is not null, its value can be set to an empty string, for example. However, since you say you are currently not handling this event, I am unsure how this is configured given the listed settings.

    So, please test the below attached sample and check out the events getting fired. My suggestion is to also make sure that the event handlers are properly hooked to the UltraGrid’s events in your project.

    Please, keep me posted on your progress.

    Sincerely,
    Bozhidara Pachilova
    Associate Software Developer

    6622.UltraGridDelKey.zip