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. Move to Next Column DataGridView

Move to Next Column DataGridView

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

    Can anyone give me a code snippet for how to move to the next column of a DataGridView to insert a value. In this case, there is no DB connectivity. I am creating an application that retrieves the property names and values for a control and populates a DataGridView with these values. I can do this: foreach (PropertyInfo prop in t.GetProperties()) { dataGridView1.Rows.Add(prop.Name); dataGridView1.Rows.Add(prop.GetValue(controls[index], null)); } However, this puts the values in the same column. I have 2 columns in the gridview, and would like the output to appear similar to the properties window in VS. Any help would be greatly appreciated. Thanks!:cool:

    "If you don't know where you're going, you'll probably end up somewhere else." Yogi Berra

    J G M 3 Replies Last reply
    0
    • M MrColeyted

      Can anyone give me a code snippet for how to move to the next column of a DataGridView to insert a value. In this case, there is no DB connectivity. I am creating an application that retrieves the property names and values for a control and populates a DataGridView with these values. I can do this: foreach (PropertyInfo prop in t.GetProperties()) { dataGridView1.Rows.Add(prop.Name); dataGridView1.Rows.Add(prop.GetValue(controls[index], null)); } However, this puts the values in the same column. I have 2 columns in the gridview, and would like the output to appear similar to the properties window in VS. Any help would be greatly appreciated. Thanks!:cool:

      "If you don't know where you're going, you'll probably end up somewhere else." Yogi Berra

      J Offline
      J Offline
      J a a n s
      wrote on last edited by
      #2

      Create an array (say string[]) of the data that you want to display. Then add it to the Rows collection of your DataGridView. Check msdn[^] for the details about DataGridView.

      *jaans

      1 Reply Last reply
      0
      • M MrColeyted

        Can anyone give me a code snippet for how to move to the next column of a DataGridView to insert a value. In this case, there is no DB connectivity. I am creating an application that retrieves the property names and values for a control and populates a DataGridView with these values. I can do this: foreach (PropertyInfo prop in t.GetProperties()) { dataGridView1.Rows.Add(prop.Name); dataGridView1.Rows.Add(prop.GetValue(controls[index], null)); } However, this puts the values in the same column. I have 2 columns in the gridview, and would like the output to appear similar to the properties window in VS. Any help would be greatly appreciated. Thanks!:cool:

        "If you don't know where you're going, you'll probably end up somewhere else." Yogi Berra

        G Offline
        G Offline
        Gopal S
        wrote on last edited by
        #3

        Hi, Here is the code snippet: foreach (PropertyInfo info in t.GetProperties()) { dataGridView1.Rows.Add(); infoName = info.Name; value = info.MemberType.ToString(); } private void dataGridView1_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e) { dataGridView1.Rows[e.RowIndex].Cells[0].Value = infoName; dataGridView1.Rows[e.RowIndex].Cells[1].Value = value; } Thanks,

        Gopal.S

        1 Reply Last reply
        0
        • M MrColeyted

          Can anyone give me a code snippet for how to move to the next column of a DataGridView to insert a value. In this case, there is no DB connectivity. I am creating an application that retrieves the property names and values for a control and populates a DataGridView with these values. I can do this: foreach (PropertyInfo prop in t.GetProperties()) { dataGridView1.Rows.Add(prop.Name); dataGridView1.Rows.Add(prop.GetValue(controls[index], null)); } However, this puts the values in the same column. I have 2 columns in the gridview, and would like the output to appear similar to the properties window in VS. Any help would be greatly appreciated. Thanks!:cool:

          "If you don't know where you're going, you'll probably end up somewhere else." Yogi Berra

          M Offline
          M Offline
          MrColeyted
          wrote on last edited by
          #4

          Thank you kindly.:cool:

          "If you don't know where you're going, you'll probably end up somewhere else." Yogi Berra

          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