Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. WPF DataGrid - automatically insert new line on tab in last visible column

WPF DataGrid - automatically insert new line on tab in last visible column

Scheduled Pinned Locked Moved WPF
questioncsharpwpfcom
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nicolai Schrade
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • N Nicolai Schrade

      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

      D Offline
      D Offline
      dasblinkenlight
      wrote on last edited by
      #2

      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.

      N 1 Reply Last reply
      0
      • D dasblinkenlight

        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.

        N Offline
        N Offline
        Nicolai Schrade
        wrote on last edited by
        #3

        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

        D 1 Reply Last reply
        0
        • N Nicolai Schrade

          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

          D Offline
          D Offline
          dasblinkenlight
          wrote on last edited by
          #4

          Yeah, that's why I suggested using the lost focus: the event figures out the last visible cell very reliably.

          N 1 Reply Last reply
          0
          • D dasblinkenlight

            Yeah, that's why I suggested using the lost focus: the event figures out the last visible cell very reliably.

            N Offline
            N Offline
            Nicolai Schrade
            wrote on last edited by
            #5

            Ah okay then I didn't understand your first post correctly. I'll give it a try... :)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups