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. Bound datagridvewview column ordering confusion

Bound datagridvewview column ordering confusion

Scheduled Pinned Locked Moved C#
helpalgorithmsquestion
2 Posts 2 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
    Matthew Cuba
    wrote on last edited by
    #1

    Hello, So, I've got a DataGridView that is bound to some data in a DataTable. I only show a subset of the columns and additionally have two non-bound columns in the DataGridView. I've attempted to set the column ordering via the DisplayIndex property to no avail. If I attempt to set the DisplayIndex for each in ascending order such as: column0.DisplayIndex = 0; column1.DisplayIndex = 1; . . . column9.DisplayIndex = 9; the columns don't order correctly. They end up showing up as follows (numbers are the order that I specified them in): 0, 1, 2, 6, 8, 4, 7, 3, 9, 5 The two non-bound columns are 6 and 8 and are DataGridViewImagaColumns. The others are text columns. Has anyone else had such a problem and solved it? I saw some similar questions asked in my google searching but didn't see a solution to this. I wonder if it is a bug or perhaps I'm just missing something here. Thanks for you help, Matt

    TODO: Think up something witty to put here.

    A 1 Reply Last reply
    0
    • M Matthew Cuba

      Hello, So, I've got a DataGridView that is bound to some data in a DataTable. I only show a subset of the columns and additionally have two non-bound columns in the DataGridView. I've attempted to set the column ordering via the DisplayIndex property to no avail. If I attempt to set the DisplayIndex for each in ascending order such as: column0.DisplayIndex = 0; column1.DisplayIndex = 1; . . . column9.DisplayIndex = 9; the columns don't order correctly. They end up showing up as follows (numbers are the order that I specified them in): 0, 1, 2, 6, 8, 4, 7, 3, 9, 5 The two non-bound columns are 6 and 8 and are DataGridViewImagaColumns. The others are text columns. Has anyone else had such a problem and solved it? I saw some similar questions asked in my google searching but didn't see a solution to this. I wonder if it is a bug or perhaps I'm just missing something here. Thanks for you help, Matt

      TODO: Think up something witty to put here.

      A Offline
      A Offline
      Adam m Nelson
      wrote on last edited by
      #2

      Hey, I don't know if there is a reason your changing the order via the DisplayIndex, or what your using to write your code, but if you right click on the datagridview and go edit columns, then you can change the order by moving them up and down in the list(In Visual Studio .NET 2005). Hope that helps, if not disregard.

      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