[RESOLVED] Datagridview Column Order Problem
Problem: I have a DGV. It has some columns. The columns are in the correct order e.g. 1,2,3,4 at design time.
When I start debugging and then come back to VS, the order of the columns have changed and I have to put them back in the correct order everytime. There about 10 columns so it gets very annoying!
After some testing I have realised it only occurs if
1) I make a change on the form that holds the DGV
2)Leave the form open in VS while I play the application ie. debug
I dont think there is a solution to this but I am hoping is someone can tell me of any options to forice VS not to alter my code or any reasons why VS is reordering my columns on its own accord?
Thanks in advance. :thumb:
Re: Datagridview Column Order Problem
Step through the program to see where (if it is consistent) it changes the columns. That will give you more information (if it is inconsistent, that is still information, but not as helpful).
Re: Datagridview Column Order Problem
Yes I would ofcourse tried this but the problem is when I am debugging i.e. running the application, the column order is correct. It is only when I exit the application that the order has changed.
I don't think there is a trace that debugs the application while running and while in design time. If there is then I'd be :eek2:
Re: Datagridview Column Order Problem
Does this happen every time? For example if you press F5 (or click run) but do not do anything and immediately click stop, does it happen then? If you must do something then set your app up so you do not have to do anything. This will help you determine what is causing it. You can also make a new form, add a grid, add columns and see if it happens there.
A fix that doesn't solve the problem would be to set the columns in code, a preferred method anyway.
Try the above steps and post your results so we can narrow it down.
Re: Datagridview Column Order Problem
I set the order in code. Use the UI to create and place the DataGridView. Once in code,
dgvCustomers.Column("FName").DisplayIndex = 0
dgvCustomers.Column("LName").DisplayIndex = 1
Then the problem becomes that the order does not always work. The following article explain how to fix that:
http://www.internetworkconsulting.ne...er-not-working
Re: Datagridview Column Order Problem
Quote:
It is only when I exit the application that the order has changed.
And if you don't mess about changing the order in the meantime what happens if you run the program again? And again? And again? If the columns are in the correct order every time the program runs irrespective then I'm really not sure why you have a problem with it!
In any case, how do you expect us to answer such a problem without benefit of code related to DGV, the design time properties or even a screen capture of the DGV at its various stages. We're just blundering about in the dark at the moment.
Re: Datagridview Column Order Problem
Quote:
Originally Posted by
dunfiddlin
And if you don't mess about changing the order in the meantime what happens if you run the program again? And again? And again? If the columns are in the correct order every time the program runs irrespective then I'm really not sure why you have a problem with it!
If the column order was OK everytime I would not have posted. I was not changing the order, in-code or using the UI. The design-time column order of the DGV was different after debugging to what it was before I had played the application. i.e. on-screen design time order - 1,2,3,4 >>> Debug/play the application >>> Do nothing/close the app >>> on-screen design time order 3,1,4,2.
Quote:
In any case, how do you expect us to answer such a problem without benefit of code related to DGV, the design time properties or even a screen capture of the DGV at its various stages. We're just blundering about in the dark at the moment.
You're only 3 years to late so I am not expecting you to do anything.
The reason I did not post any code was because the problem was only occurring at design time. Run-time code would not have affected this. I would of provided screenshots and code should someone answering the question have asked.
I put it down to my project solution files and VS2008 as it didn't occur in 2010. Closed.