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?
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 PachilovaAssociate Software Developer
6622.UltraGridDelKey.zip
Hello Bozhidara
Thank you for your answer.
In your sample project you set CellCliclAction to EditAndSelectText. I did not have this (see my last post). If users click a cell, the cell just get selected. But anyway, if I change your sample to this, it is still working - but not in my grid.
Therefore I looking for some settings in my grid that can influence the behaviour of the DEL-Key KeyPress-Event.
My grid is representing a activity plan for employees on day basis. Columns are calendar days, Rows are organisations while Band0 are departments, Band1 employees, Band2 day-notes. The cell we are talking about is on band1. The cell shows a activity-code and if users press DEL-Key I have have to capture this to execute some business rules, delete the activityplan at the date etc. EditMode ist started in KeyPress-Event if users press DigitOrLetter-Key. Validation of valid activity-code ist checked in BeforeExitEditMode and AfterExitEditMode executes the business rules (also if all text is deleted in edit mode).
The grid setup has 3 fixed columns left. On employee rows (band1) cell appearance and cell activation can be setup on some cells depending on activity states, locked cells are setup if no employment, etc.
I have tried to comment out most of the layout code - but still no KeyPress-Event.
Do you have any ideas which settings can influence the DEL-Key?
Thank you for any help.
Markus