WPF DataGrid - automatically insert new line on tab in last visible column
-
Hi, another datagrid question :=) I searched the web for this, but unfortunatelly did not find anything useful. What I want to achieve is, if the user presses tab on the last visible column of a datagrid, it should automatically create the new line and open the first line for editing data. So if I'm here: Screenshot 1 and press tab the datagrid should do this: Screenshot 2 Any ideas? Kind regards, Nico
-
Hi, another datagrid question :=) I searched the web for this, but unfortunatelly did not find anything useful. What I want to achieve is, if the user presses tab on the last visible column of a datagrid, it should automatically create the new line and open the first line for editing data. So if I'm here: Screenshot 1 and press tab the datagrid should do this: Screenshot 2 Any ideas? Kind regards, Nico
Assuming the default TAB behavior (i.e. tabbing out of the final cell moves the focus from the grid to the next control) I would try providing a LostKeyboardFocus that inserts a row, and brings the focus back into the initial cell of that newly inserted row. P.S. This may or may not work when there are no other controls on the page: I do not know if you get a LostKeyboardFocus+GotKeyboardFocus when the focus circles back to the same control.
-
Assuming the default TAB behavior (i.e. tabbing out of the final cell moves the focus from the grid to the next control) I would try providing a LostKeyboardFocus that inserts a row, and brings the focus back into the initial cell of that newly inserted row. P.S. This may or may not work when there are no other controls on the page: I do not know if you get a LostKeyboardFocus+GotKeyboardFocus when the focus circles back to the same control.
Okay thanks for your answer :) But I don't think this is the way I want to go. I thought about something like: - Event "CurrentCellChanged" or something similar - If my cursor was in the last visible column and the user pressed "TAB" then do something But I had no luck putting this correctly together. I have extreme problems finding out if the Current Cell is in the last visible column... :( Kind regards, nico
-
Okay thanks for your answer :) But I don't think this is the way I want to go. I thought about something like: - Event "CurrentCellChanged" or something similar - If my cursor was in the last visible column and the user pressed "TAB" then do something But I had no luck putting this correctly together. I have extreme problems finding out if the Current Cell is in the last visible column... :( Kind regards, nico
Yeah, that's why I suggested using the lost focus: the event figures out the last visible cell very reliably.
-
Yeah, that's why I suggested using the lost focus: the event figures out the last visible cell very reliably.
Ah okay then I didn't understand your first post correctly. I'll give it a try... :)