C# DataTable/Datagridview columns

Visual Studio DataTable/Datagridview column order issues

Page 1 of 1

2 Replies - 6405 Views - Last Post: 08 September 2010 - 09:12 AM Rate Topic: -----

#1 mjw85  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 52
  • Joined: 01-October 07

C# DataTable/Datagridview columns

Posted 08 September 2010 - 06:31 AM

Hello,
I am currently working with a Datagridview that is bound to a datatable. The information is pulling correctly, however, I am confused as far as column order. Half of my columns come from the datatable itself (which is pulled from a database), while half are set in the datagridview(such as check boxes, and other items that are filled in by the user). Is there a better way I can go about adding the columns so they are in the order I want?

Thanks! :bigsmile:

Is This A Good Question/Topic? 0
  • +

Replies To: C# DataTable/Datagridview columns

#2 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 5103
  • View blog
  • Posts: 9,283
  • Joined: 08-June 10

Re: C# DataTable/Datagridview columns

Posted 08 September 2010 - 07:12 AM

Yes, don't auto-generate columns. Manually create them all, in the order you want, and set the AutoGenerateColumns property to false.
Was This Post Helpful? 3
  • +
  • -

#3 mjw85  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 52
  • Joined: 01-October 07

Re: C# DataTable/Datagridview columns

Posted 08 September 2010 - 09:12 AM

Thank you for your help. I have successfully added columns manually to the datagridview, but have issues when trying to set the auto generate property to false - the code will no longer run. Additionally, when I try to sort them, the datatable is still showing last in the columns. Is there any way to set to code to where the datatable will appear first in the columns, not the manually entered columns?
Thanks! :bigsmile:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1