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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. DataGridView and DataSets

DataGridView and DataSets

Scheduled Pinned Locked Moved C#
questiondatabasewinformshelp
5 Posts 4 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.
  • I Offline
    I Offline
    Illegal Operation
    wrote on last edited by
    #1

    I have a dataset that contains a query stateing the following: select * from table where id = @id. This query works fine. The problem I am having is that I have 2 Windows forms, Form1 contains a datagrid and Form2 contains the textboxes, comboboxes etc. How can I double click on a record in the datagrid and then that record should populate form2? I know it should be handled in the datagrid_doubleclick method but How can I let Form2 know that I have double clicked on id 1?

    Illegal Operation

    J X S 3 Replies Last reply
    0
    • I Illegal Operation

      I have a dataset that contains a query stateing the following: select * from table where id = @id. This query works fine. The problem I am having is that I have 2 Windows forms, Form1 contains a datagrid and Form2 contains the textboxes, comboboxes etc. How can I double click on a record in the datagrid and then that record should populate form2? I know it should be handled in the datagrid_doubleclick method but How can I let Form2 know that I have double clicked on id 1?

      Illegal Operation

      J Offline
      J Offline
      Jack Li
      wrote on last edited by
      #2

      you'll setting dataSet public,when form2 load and for form2 data

      I 1 Reply Last reply
      0
      • J Jack Li

        you'll setting dataSet public,when form2 load and for form2 data

        I Offline
        I Offline
        Illegal Operation
        wrote on last edited by
        #3

        Can you possibly give me an example of what you are saying?

        Illegal Operation

        1 Reply Last reply
        0
        • I Illegal Operation

          I have a dataset that contains a query stateing the following: select * from table where id = @id. This query works fine. The problem I am having is that I have 2 Windows forms, Form1 contains a datagrid and Form2 contains the textboxes, comboboxes etc. How can I double click on a record in the datagrid and then that record should populate form2? I know it should be handled in the datagrid_doubleclick method but How can I let Form2 know that I have double clicked on id 1?

          Illegal Operation

          X Offline
          X Offline
          Xmen Real
          wrote on last edited by
          #4

          use MouseDoubleClick instead...

          Point p = dataGridView1.PointToClient(new Point(e.X, e.Y));
          DataGridView.HitTestInfo tmp_hinfo = dataGridView1.HitTest(p.X, p.Y);
          if (tmp_hinfo.RowIndex == -1 || tmp_hinfo.ColumnIndex == -1)
          return;
          // Now you have row index and column index

          TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i’TV.C\y<pŠjxsg-b$f4ia> -------------------------------------------------------- 128 bit encrypted signature, crack if you can

          1 Reply Last reply
          0
          • I Illegal Operation

            I have a dataset that contains a query stateing the following: select * from table where id = @id. This query works fine. The problem I am having is that I have 2 Windows forms, Form1 contains a datagrid and Form2 contains the textboxes, comboboxes etc. How can I double click on a record in the datagrid and then that record should populate form2? I know it should be handled in the datagrid_doubleclick method but How can I let Form2 know that I have double clicked on id 1?

            Illegal Operation

            S Offline
            S Offline
            Samuel Cherinet
            wrote on last edited by
            #5

            what you can do is provide an overload constructor for the second form that takes a datarow as a parameter public Form2(DataRow drow):this() { //fill the data by indexing through all the values this.text1.text=drow["Name"].ToString(); } and as to figuring out which data that has been selected just handle "CellDoubleClick" and/or "RowHeaderMouseDoubleClick" events and then send the datarow selected by using the selected row from the event handler argument. like in this code: private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { new Form2(dataGridView1.Rows[e.RowIndex].DataBoundItem).Show(); } hope this does the trick for you

            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