Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

datagridview c# reorder columns on bind

Posted on 2008-06-09
8
Medium Priority
?
1,484 Views
Last Modified: 2012-06-22
My columns are correct in the designer.  when I bind to my ds, they are getting reordered. What is going on?
0
Comment
Question by:jackjohnson44
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
8 Comments
 
LVL 14

Expert Comment

by:Daniel Junges
ID: 21745568
you have to add the dataset into you designer
- Set the datasource
- right click on the dataset and edit the columns

because you are binding it later then the columns from datagridview are redefined
0
 

Author Comment

by:jackjohnson44
ID: 21745647
I am creating the columns in the designer and binding at run time, not in the designer.
0
 
LVL 14

Accepted Solution

by:
Daniel Junges earned 2000 total points
ID: 21745719
wen you bind at the runtime then the designed columns are lost. On bind at runtime the Columns are automatically redefined.

you can do the follow on you code:

DataGridViewColumn[] columns = new DataGridViewColumn[dataGridView1.Columns.Count];
 
dataGridView1.DataSource = ...;
dataGridView1.DataMember = ...;
 
dataGridView1.Columns.CopyTo( columns, 0 );
dataGridView1.Columns.Clear();
dataGridView1.Columns.AddRange(columns);

Open in new window

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:jackjohnson44
ID: 21752886
Isn't there a way to stop that from happening?  I thought that there was a flag that you could set or something.
0
 
LVL 14

Expert Comment

by:Daniel Junges
ID: 22002576
I have posted a solution on this thread. I mean admins cannot simply delete solved questions .....
regards
junges
0
 

Author Closing Comment

by:jackjohnson44
ID: 31465502
sorry for the delay, I just moved and did not have an internet connection for weeks
0
 
LVL 2

Expert Comment

by:sriraj2000
ID: 26039654
This cannot be treated as the right solution unless the person who has questioned this has accepted this.  I have the same problem and I do not think that this is the solution for this.
0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question