المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : DatagridViewColumn displayIndex - column order wrong after setting them from control settings table.



C# Programming
02-20-2010, 07:13 PM
Hi,

I have a datagridview upon which I allow the user to re-order the columns. I then store the column order in a sqlServer database table. When the user starts the datagridview my code reads the database and retreives the user's column positions.

The code loops through the columns and sets the displayIndex as previously saved. No problems except the columns are displayed in the wrong orderhttp://www.barakasoft.com/script/Forums/Images/smiley_confused.gif The effect is rather inconsistent and not all the columns are in the wrong order.

Under the debugger I can see the displayindices are correctly set as per the database table. The columns just appear in the wrong place on-screenhttp://www.barakasoft.com/script/Forums/Images/smiley_squeamish.gif
I have a fix http://www.barakasoft.com/script/Forums/Images/smiley_smile.gif I simply run the code that sets the displayIndices twice. The problem goes away (well up to now).

I wonder if anyone has had similar displayIndex problems and has a better fix? I have one or two comments in my code saying //DONT REMOVE THIS CODE. IT LOOKS WRONG BUT IS FIXING AN ISSUE.

Terry