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. Looping Though A DataGridView?

Looping Though A DataGridView?

Scheduled Pinned Locked Moved C#
csharpdatabasequestion
4 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.
  • H Offline
    H Offline
    Harvey Saayman
    wrote on last edited by
    #1

    Hey Guys, i have a dataGridView control on my form with only one column of type string. Now i need to get all the strings out of it one by one... how would i do that cuz it cant foreach thanx

    Harvey Saayman - South Africa Junior Developer .Net, C#, SQL think BIG and kick ASS

    you.suck = (you.passion != Programming)
    
    J C 2 Replies Last reply
    0
    • H Harvey Saayman

      Hey Guys, i have a dataGridView control on my form with only one column of type string. Now i need to get all the strings out of it one by one... how would i do that cuz it cant foreach thanx

      Harvey Saayman - South Africa Junior Developer .Net, C#, SQL think BIG and kick ASS

      you.suck = (you.passion != Programming)
      
      J Offline
      J Offline
      Justin Perez
      wrote on last edited by
      #2

      for(int i = 0; i < dataGridView.Rows.Count; i++) {
      Console.WriteLine(dataGridView.Rows[i][0]); }

      I'm going to become rich when I create a device that allows me to punch people in the face over the internet. "If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer

      H 1 Reply Last reply
      0
      • H Harvey Saayman

        Hey Guys, i have a dataGridView control on my form with only one column of type string. Now i need to get all the strings out of it one by one... how would i do that cuz it cant foreach thanx

        Harvey Saayman - South Africa Junior Developer .Net, C#, SQL think BIG and kick ASS

        you.suck = (you.passion != Programming)
        
        C Offline
        C Offline
        Charith Jayasundara
        wrote on last edited by
        #3

        Hi, Here is the code for foreach DataGridView grvCompany = new ....; foreach (DataGridViewRow row in grvCompany.Rows) { // } Thanks! Charith

        jayasshc

        1 Reply Last reply
        0
        • J Justin Perez

          for(int i = 0; i < dataGridView.Rows.Count; i++) {
          Console.WriteLine(dataGridView.Rows[i][0]); }

          I'm going to become rich when I create a device that allows me to punch people in the face over the internet. "If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer

          H Offline
          H Offline
          Harvey Saayman
          wrote on last edited by
          #4

          Hey, thanx for the reply... that was the logical sollution for me too, but it doesnt allow the 2nd index (the one for the column) i tried these and they did not work foreach (DataGridViewRow row in pollTimesDataGridView) { string myString = row[0]; MessageBox.Show(myString); } for (int i = 0; i < pollTimesDataGridView.Rows.Count; i++) { MessageBox.Show(pollTimesDataGridView.Rows[i][0]); } any ideas? thanx justin

          Harvey Saayman - South Africa Junior Developer .Net, C#, SQL think BIG and kick ASS

          you.suck = (you.passion != Programming)
          
          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