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. Create a new row at the bottom of DataGrid (When User Click on Button(Out side of DataGrid))

Create a new row at the bottom of DataGrid (When User Click on Button(Out side of DataGrid))

Scheduled Pinned Locked Moved WPF
csharpcsswpfquestionannouncement
6 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.
  • T Offline
    T Offline
    TweakBird
    wrote on last edited by
    #1

    Hi All, I have to take the inputs as multiple entries in WPF data grid like this. ---------------------------------------------------------------------------------------------------------------------- | Select Option | Name | Age |Country | Action | Action | ---------------------------------------------------------------------------------------------------------------------- | option button | textbox | textbox | combobox | linkbutton edit/update row | linkbutton edit row | ------------------------------------------------------------------------------------------------------------ ADD Button ----------------------------------------------- --> By clicking the ADD button i have to create a new row with new controls as in 2nd row. --> By clicking the DELETE button in the 5th cell the corresponding row should be deleted. --> By clicking the EDIT button in the 4th cell the corresponding row should be UPDATED(if user want) Can I achieve this by taking WPF Data grid (WPF tool Kit Latest Build ), and how? Or is there any other ways to achieve this? Suggest me some URLs, Samples..etc Many Many Thanks in Advance. Eswara G

    M 1 Reply Last reply
    0
    • T TweakBird

      Hi All, I have to take the inputs as multiple entries in WPF data grid like this. ---------------------------------------------------------------------------------------------------------------------- | Select Option | Name | Age |Country | Action | Action | ---------------------------------------------------------------------------------------------------------------------- | option button | textbox | textbox | combobox | linkbutton edit/update row | linkbutton edit row | ------------------------------------------------------------------------------------------------------------ ADD Button ----------------------------------------------- --> By clicking the ADD button i have to create a new row with new controls as in 2nd row. --> By clicking the DELETE button in the 5th cell the corresponding row should be deleted. --> By clicking the EDIT button in the 4th cell the corresponding row should be UPDATED(if user want) Can I achieve this by taking WPF Data grid (WPF tool Kit Latest Build ), and how? Or is there any other ways to achieve this? Suggest me some URLs, Samples..etc Many Many Thanks in Advance. Eswara G

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      If the itemssource for the datagrid is an observablecollection, generally all you need to do is add or remove items from the collection and the datagrid will update appropriately. How are you providing data to the datagrid?

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      T 1 Reply Last reply
      0
      • M Mark Salsbery

        If the itemssource for the datagrid is an observablecollection, generally all you need to do is add or remove items from the collection and the datagrid will update appropriately. How are you providing data to the datagrid?

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        T Offline
        T Offline
        TweakBird
        wrote on last edited by
        #3

        Hi Mark Salsbery, Thanks for Quick Reply, Right now am providing data by using DataSet like dgXXX.ItemsSource= dataSetXX.Tables[0].DefaultView; Case 1: How to convert Data set to observablecollection.. case 2. i have some limitations, a) I am retrieving data as DataSet from Oracle11g by using Ref_cursor. Now ... Please suggest me a way to approach. Thanks Eswara G

        M 1 Reply Last reply
        0
        • T TweakBird

          Hi Mark Salsbery, Thanks for Quick Reply, Right now am providing data by using DataSet like dgXXX.ItemsSource= dataSetXX.Tables[0].DefaultView; Case 1: How to convert Data set to observablecollection.. case 2. i have some limitations, a) I am retrieving data as DataSet from Oracle11g by using Ref_cursor. Now ... Please suggest me a way to approach. Thanks Eswara G

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          You should be able to use the DataTable as-is if I remember right. dataSetXX.Tables[0].Rows is the collection you can add/delete items from (using DataTable.NewRow() to create new rows to insert). dgXXX.SelectedItem should give you the DataRow selected in the datagrid. Here's some more info: Windows Presentation Foundation Data Binding: Part 2[^]

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          T 1 Reply Last reply
          0
          • M Mark Salsbery

            You should be able to use the DataTable as-is if I remember right. dataSetXX.Tables[0].Rows is the collection you can add/delete items from (using DataTable.NewRow() to create new rows to insert). dgXXX.SelectedItem should give you the DataRow selected in the datagrid. Here's some more info: Windows Presentation Foundation Data Binding: Part 2[^]

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            T Offline
            T Offline
            TweakBird
            wrote on last edited by
            #5

            Thank you Mark.. I tried this way..But am unable complete my requirement... Can you provide me some sample code or Application or URL.. Regards, Eswara G

            M 1 Reply Last reply
            0
            • T TweakBird

              Thank you Mark.. I tried this way..But am unable complete my requirement... Can you provide me some sample code or Application or URL.. Regards, Eswara G

              M Offline
              M Offline
              Mark Salsbery
              wrote on last edited by
              #6

              Eswa wrote:

              Can you provide me some sample code or Application or URL..

              Here's one example (see first reply): Binding a WPF listview to a DataTable[^] An article with a little background in it: How do I bind to ADO.NET?[^] If you can show a simple example of what you tried that didn't work then maybe I can see what's going on...

              Mark Salsbery Microsoft MVP - Visual C++ :java:

              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