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. C#
  4. datagridview c#

datagridview c#

Scheduled Pinned Locked Moved C#
csharp
6 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.
  • M Offline
    M Offline
    missoby
    wrote on last edited by
    #1

    Hello Everyone :) I begin to develop an application using C #, but I can not handle the DataGridView has actually :sigh: I manage to display data from a table but after posting I need to recover the contained of a cell but I can not :( !! in fact I want to use the datagrid to manage user profile (add, edit and delete). pleaaaaaaase i need your helppp !!!!! :(

    B P 2 Replies Last reply
    0
    • M missoby

      Hello Everyone :) I begin to develop an application using C #, but I can not handle the DataGridView has actually :sigh: I manage to display data from a table but after posting I need to recover the contained of a cell but I can not :( !! in fact I want to use the datagrid to manage user profile (add, edit and delete). pleaaaaaaase i need your helppp !!!!! :(

      B Offline
      B Offline
      BobJanova
      wrote on last edited by
      #2

      I need to recover the contained of a cell but I can not This doesn't make sense. Did you mean 'content'? The DGV allows you to access cells directly: myDGV.Cells[2, 6].Value.

      M 1 Reply Last reply
      0
      • B BobJanova

        I need to recover the contained of a cell but I can not This doesn't make sense. Did you mean 'content'? The DGV allows you to access cells directly: myDGV.Cells[2, 6].Value.

        M Offline
        M Offline
        missoby
        wrote on last edited by
        #3

        yes i mean the content of the cell!! i tried your methode (dataGridView1.Cells [1, 1].value;) but "Cells" does not exist (an assembly reference is messing) :/ i tried also ( oConnexion.Open(); reader = command.ExecuteReader(); DataTable DataTable1 = new DataTable(); DataTable1.Load(reader); foreach (DataRow row in DataTable1.Rows) { foreach (DataColumn column in DataTable1.Columns) { MessageBox.Show(column.DataType.ToString()); MessageBox.Show(column.DefaultValue.ToString()); MessageBox.Show(column.ToString()); column.DataType.ToString(); MessageBox.Show(column.Table.Rows[0].ToString()); MessageBox.Show(column.ExtendedProperties.ToString()); textBox1.AppendText(row[column].ToString()); textBox1.AppendText((string)(row[column])); textBox1.AppendText(" | "); } textBox1.AppendText("\r\n--------------\r\n"); } }) but it return the whole column not only one cell :/

        B 1 Reply Last reply
        0
        • M missoby

          yes i mean the content of the cell!! i tried your methode (dataGridView1.Cells [1, 1].value;) but "Cells" does not exist (an assembly reference is messing) :/ i tried also ( oConnexion.Open(); reader = command.ExecuteReader(); DataTable DataTable1 = new DataTable(); DataTable1.Load(reader); foreach (DataRow row in DataTable1.Rows) { foreach (DataColumn column in DataTable1.Columns) { MessageBox.Show(column.DataType.ToString()); MessageBox.Show(column.DefaultValue.ToString()); MessageBox.Show(column.ToString()); column.DataType.ToString(); MessageBox.Show(column.Table.Rows[0].ToString()); MessageBox.Show(column.ExtendedProperties.ToString()); textBox1.AppendText(row[column].ToString()); textBox1.AppendText((string)(row[column])); textBox1.AppendText(" | "); } textBox1.AppendText("\r\n--------------\r\n"); } }) but it return the whole column not only one cell :/

          B Offline
          B Offline
          BobJanova
          wrote on last edited by
          #4

          Is this the WinForms DataGridView? Turns out I was remembering something else, you can't index it like that, you have to do myDgv.Rows[2].Cells[3].Value. And, uh, of course that example gets the whole column because it loops over all rows! Programming isn't something you should just hack around and hope something works (well, no discipline is like that really) – if you can't read that snippet and work out that it will get a table from a data source and then construct text output for the whole table, you need to go back to basics and make sure you've got the language structures (loops and so on) and the classes (data and UI) straight in your head.

          C 1 Reply Last reply
          0
          • M missoby

            Hello Everyone :) I begin to develop an application using C #, but I can not handle the DataGridView has actually :sigh: I manage to display data from a table but after posting I need to recover the contained of a cell but I can not :( !! in fact I want to use the datagrid to manage user profile (add, edit and delete). pleaaaaaaase i need your helppp !!!!! :(

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #5

            DataGridView is filth and shouldn't be used for "real work".

            missoby wrote:

            I want to ... manage user profile

            Write a proper Form for doing that -- your users will thank you.

            1 Reply Last reply
            0
            • B BobJanova

              Is this the WinForms DataGridView? Turns out I was remembering something else, you can't index it like that, you have to do myDgv.Rows[2].Cells[3].Value. And, uh, of course that example gets the whole column because it loops over all rows! Programming isn't something you should just hack around and hope something works (well, no discipline is like that really) – if you can't read that snippet and work out that it will get a table from a data source and then construct text output for the whole table, you need to go back to basics and make sure you've got the language structures (loops and so on) and the classes (data and UI) straight in your head.

              C Offline
              C Offline
              Caleb McElrath
              wrote on last edited by
              #6

              BobJanova wrote:

              Programming isn't something you should just hack around and hope something works

              I actually know a couple of well respected developers that have mastered the ability to "just hack around". A sort of meta-p.o.c. type development. The things that work correctly, stick, while the things that do not, changes until it works correctly. QA/QC would be obsolete if everything worked the first time -which is realistically known as inconceivable. The type previously described is one way to make it to QA. I take a different approach personally but, it really doesn't matter as long as the code functions as required, is maintainable, and is complete in the allotted time. What are "best practices" anyways other than socially acceptable opinions? Don't get me wrong, I do tend to agree with development best practices but when it comes down to it, it is merely an officially accepted opinion on how things should be.

              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