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. Database & SysAdmin
  3. Database
  4. How to iterate thru all the elements of Datagrid (windows forms)

How to iterate thru all the elements of Datagrid (windows forms)

Scheduled Pinned Locked Moved Database
csharpquestionwinformstutorial
12 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.
  • C Christian Graus

    Doesn't the DataGrid have a Rows property, which has a Count property ?

    Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

    R Offline
    R Offline
    Rocky
    wrote on last edited by
    #3

    OK got ur point, stupid question I know:doh:

    R 1 Reply Last reply
    0
    • R Rocky

      OK got ur point, stupid question I know:doh:

      R Offline
      R Offline
      Rocky
      wrote on last edited by
      #4

      wait a second here I think this property is not therein Windows Forms, I might still be wrong though, I'm sorry for taht in advance but I got the other way around to this like DataTable dt = (DataTable) dg.DataSource; dt.Rows.Count casting the DataGrids Datasource into a table and then using its count but I'm not so sure if it will work when the using is giving data for input

      R 1 Reply Last reply
      0
      • R Rocky

        wait a second here I think this property is not therein Windows Forms, I might still be wrong though, I'm sorry for taht in advance but I got the other way around to this like DataTable dt = (DataTable) dg.DataSource; dt.Rows.Count casting the DataGrids Datasource into a table and then using its count but I'm not so sure if it will work when the using is giving data for input

        R Offline
        R Offline
        Rocky
        wrote on last edited by
        #5

        Just one more question here, God I'm a real new commer here, ah how do u empty a datagrid. I want the datagrid showing an existing set of records to get empty when I click a button for adding a new record. Its actually a master detail form. The master table is linked with a set of textboxes and comboboxes and The details are in the datagrid. I hope the scenario is clear now and I repeat I'm using .net 1.1 and working in Windows Forms. So I need the info abt System.windows.Forms not the other one thanks in advance... Rocky

        I 1 Reply Last reply
        0
        • R Rocky

          Just one more question here, God I'm a real new commer here, ah how do u empty a datagrid. I want the datagrid showing an existing set of records to get empty when I click a button for adding a new record. Its actually a master detail form. The master table is linked with a set of textboxes and comboboxes and The details are in the datagrid. I hope the scenario is clear now and I repeat I'm using .net 1.1 and working in Windows Forms. So I need the info abt System.windows.Forms not the other one thanks in advance... Rocky

          I Offline
          I Offline
          Izak
          wrote on last edited by
          #6

          clear the datascource grdDetails.DataSource = Nothing

          R 1 Reply Last reply
          0
          • I Izak

            clear the datascource grdDetails.DataSource = Nothing

            R Offline
            R Offline
            Rocky
            wrote on last edited by
            #7

            Thanks I got this idea a little while b4 I read this but I really appreciate it.

            R 1 Reply Last reply
            0
            • R Rocky

              Thanks I got this idea a little while b4 I read this but I really appreciate it.

              R Offline
              R Offline
              Rocky
              wrote on last edited by
              #8

              Well right now I'm working on that same form to save the data. I've made the sqlDataadapters for the master and the detail tables which offcourse have the update,select insert, del commands. But I'm a bit confused in whether if I should add() the new row of data in the master table b4 taking the input from the datagrid or not. Can anyone plz give me a few guidlines or a tip or 2 abt this. I'm doin this for the first time actually. If u can give any useful Urls, that wuold be nice too. thanks

              R 1 Reply Last reply
              0
              • R Rocky

                Well right now I'm working on that same form to save the data. I've made the sqlDataadapters for the master and the detail tables which offcourse have the update,select insert, del commands. But I'm a bit confused in whether if I should add() the new row of data in the master table b4 taking the input from the datagrid or not. Can anyone plz give me a few guidlines or a tip or 2 abt this. I'm doin this for the first time actually. If u can give any useful Urls, that wuold be nice too. thanks

                R Offline
                R Offline
                Rocky
                wrote on last edited by
                #9

                Can anybuddy provide me some good helping material (reading, code etc) for making master detail forms (C# preferably)

                _ 1 Reply Last reply
                0
                • R Rocky

                  Can anybuddy provide me some good helping material (reading, code etc) for making master detail forms (C# preferably)

                  _ Offline
                  _ Offline
                  _AK_
                  wrote on last edited by
                  #10

                  You can get so many examples on net for that if you will use google : :) here is the one: http://msdn2.microsoft.com/en-us/library/c12c1kx4.aspx

                  Best Regards, Apurva Kaushal

                  R 1 Reply Last reply
                  0
                  • _ _AK_

                    You can get so many examples on net for that if you will use google : :) here is the one: http://msdn2.microsoft.com/en-us/library/c12c1kx4.aspx

                    Best Regards, Apurva Kaushal

                    R Offline
                    R Offline
                    Rocky
                    wrote on last edited by
                    #11

                    Thanks a lot, I appreciate it. yesterday I worked on the form and its del command is working allright now. I havent worked on updates as yet. I'm having a little problem in inserting data in the detail table. Its shown in a datagrid and I dont know, the records get inserted automatically thru the grid. Its strange for me. How can we stop this behaviour ir use it more inteligently for our purpose? Thanks a lot...

                    R 1 Reply Last reply
                    0
                    • R Rocky

                      Thanks a lot, I appreciate it. yesterday I worked on the form and its del command is working allright now. I havent worked on updates as yet. I'm having a little problem in inserting data in the detail table. Its shown in a datagrid and I dont know, the records get inserted automatically thru the grid. Its strange for me. How can we stop this behaviour ir use it more inteligently for our purpose? Thanks a lot...

                      R Offline
                      R Offline
                      Rocky
                      wrote on last edited by
                      #12

                      private void MakeReadOnly() { dataGridView1.AllowUserToAddRows = false; dataGridView1.AllowUserToDeleteRows = false; dataGridView1.ReadOnly = true; } I think I got the clue here. is that it?:)

                      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