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. .NET (Core and Framework)
  4. Column Order in a DataGridView with BindingList as DataSource

Column Order in a DataGridView with BindingList as DataSource

Scheduled Pinned Locked Moved .NET (Core and Framework)
helpcsharptutoriallounge
2 Posts 1 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.
  • K Offline
    K Offline
    KoRUPT
    wrote on last edited by
    #1

    I am having problems getting the column order in a DataGridView object to display how I want it. Here are my objects: Data object class CData { //data members private uint id; private string name; private object otherstuff; //constructor ... //standard //get / set public uint ID{ get{ return id; } set{ id = value; } } ... //basic get/set for the other data members I then create multiple CData objects and place them in a List<CData> object "myList". When I go to bind this list to a DataGridView I use the following code BindingList<CData> bindlist = new BindingList<CData>(myList); myDataGridView.DataSource = bindlist; myDataGridView.Refresh() the problem comes when my form is shown and my data is presented. Currently I can not figure out how to order the columns generated from my CData class properties. By default I thought they would show up in the order that they are declared like: | ID | Name | OtherData | but I find that the order is chosen at random (or some other factor I can not figure out) and they display something like: | OtherData | ID | Name | Now normally this wouldnt be too big of a problem but in my real world application I am using a Data object with over 100 fields which are generated from a file with a strict structure layout and it is critical that I see my columns in the proper order. I hope I explained this properly and would appreciate any help that can be offered on the matter. Thank you. PS: If some moderator or something feels I will get more response in the C# forum, please move this post or advise me to move it. There are only 10 types of people in this world; Those who understand binary, and those who don't. -- modified at 17:30 Friday 27th January, 2006

    K 1 Reply Last reply
    0
    • K KoRUPT

      I am having problems getting the column order in a DataGridView object to display how I want it. Here are my objects: Data object class CData { //data members private uint id; private string name; private object otherstuff; //constructor ... //standard //get / set public uint ID{ get{ return id; } set{ id = value; } } ... //basic get/set for the other data members I then create multiple CData objects and place them in a List<CData> object "myList". When I go to bind this list to a DataGridView I use the following code BindingList<CData> bindlist = new BindingList<CData>(myList); myDataGridView.DataSource = bindlist; myDataGridView.Refresh() the problem comes when my form is shown and my data is presented. Currently I can not figure out how to order the columns generated from my CData class properties. By default I thought they would show up in the order that they are declared like: | ID | Name | OtherData | but I find that the order is chosen at random (or some other factor I can not figure out) and they display something like: | OtherData | ID | Name | Now normally this wouldnt be too big of a problem but in my real world application I am using a Data object with over 100 fields which are generated from a file with a strict structure layout and it is critical that I see my columns in the proper order. I hope I explained this properly and would appreciate any help that can be offered on the matter. Thank you. PS: If some moderator or something feels I will get more response in the C# forum, please move this post or advise me to move it. There are only 10 types of people in this world; Those who understand binary, and those who don't. -- modified at 17:30 Friday 27th January, 2006

      K Offline
      K Offline
      KoRUPT
      wrote on last edited by
      #2

      bump to the first page. I still need help on this issue. There are only 10 types of people in this world; Those who understand binary, and those who don't.

      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