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 cell click

WPF DataGrid cell click

Scheduled Pinned Locked Moved WPF
questionhelpcsharpdatabasewpf
5 Posts 3 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.
  • L Offline
    L Offline
    LAPEC
    wrote on last edited by
    #1

    Hello Everyone I have this slight problem maybe someone can help me please... I have created a WPF project on VS2010. In this project I have a window with one DataGrid (on the left side of the window), seven TextBoxes, two ComboBoxes and one CheckBox (on the right side of the window). When I run application, on the DataGrid I display only the name of employee from the database. My Question: How can I display all the details of the employee in the textboxes, comboboxes, and checkbox when I click on the cell of the datagrid? Could someone help me on this please I'm new to WPF... Kind Regards to everyone Lapeci

    E J 2 Replies Last reply
    0
    • L LAPEC

      Hello Everyone I have this slight problem maybe someone can help me please... I have created a WPF project on VS2010. In this project I have a window with one DataGrid (on the left side of the window), seven TextBoxes, two ComboBoxes and one CheckBox (on the right side of the window). When I run application, on the DataGrid I display only the name of employee from the database. My Question: How can I display all the details of the employee in the textboxes, comboboxes, and checkbox when I click on the cell of the datagrid? Could someone help me on this please I'm new to WPF... Kind Regards to everyone Lapeci

      E Offline
      E Offline
      Erik Rude
      wrote on last edited by
      #2

      You could consider presenting your data in a ListBox or a ListView and set IsSyncronisedWithCurrentItem="True" using the autamatic Parent Child binding in WPF.

      L 1 Reply Last reply
      0
      • E Erik Rude

        You could consider presenting your data in a ListBox or a ListView and set IsSyncronisedWithCurrentItem="True" using the autamatic Parent Child binding in WPF.

        L Offline
        L Offline
        LAPEC
        wrote on last edited by
        #3

        Is any way to do it with datagrid rather then with listbox, and is it possible to show me with some sample code according to my question please... kind regards lapeci

        E 1 Reply Last reply
        0
        • L LAPEC

          Hello Everyone I have this slight problem maybe someone can help me please... I have created a WPF project on VS2010. In this project I have a window with one DataGrid (on the left side of the window), seven TextBoxes, two ComboBoxes and one CheckBox (on the right side of the window). When I run application, on the DataGrid I display only the name of employee from the database. My Question: How can I display all the details of the employee in the textboxes, comboboxes, and checkbox when I click on the cell of the datagrid? Could someone help me on this please I'm new to WPF... Kind Regards to everyone Lapeci

          J Offline
          J Offline
          Jeremy Hutchinson
          wrote on last edited by
          #4

          There are two ways to do this: 1. Bind the DataGrid's SelectItem to a property in your ViewModel (or code behind if you're not using MVVM :( ), then in the setter for that property populate properties for the TextBoxes, ComboBoxes etc. This method has the advantage of being able to add a Cancel button. 2. Bind the TextBoxes, ComboBoxes etc to the DataGrid's SelectedItem property. Something like this:

          {Binding ElementName=DataGrid1, Path=SelectedItem.TextPropertyName}

          This method saves you a bit of coding but doesn't offer an easy way to cancel changes.

          My Blog[^] Chess Tactics for WP7[^]

          1 Reply Last reply
          0
          • L LAPEC

            Is any way to do it with datagrid rather then with listbox, and is it possible to show me with some sample code according to my question please... kind regards lapeci

            E Offline
            E Offline
            Erik Rude
            wrote on last edited by
            #5

            I don't know any quick way to do it with Grid, but you can get a very similar look by using a list view - maybe something along these lines: Other than that wait for some one else to come up with the answer. Or read up on Binding.

            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