Solved

Datagridview column reorder problem

Posted on 2009-03-31
5
524 Views
Last Modified: 2013-11-26
hi all,

i have implemented a datagridview with column reorder functionality. it is working fine, like a am able to drag and drop columns whereever i want them.
now the problem arises when i put a for loop to check the current position of columns, the current position is still unchanged i.e. i put II nd column to the position of iV th column but still i get column 2 at IInd position.

Column reorder doesn't affect the actual column position.


any sort of help would be appreciated.

thanks
0
Comment
Question by:replyanshu
  • 2
5 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 24048467
How are you "checking" for column order?  Are you just looping through the columns, or are you checking a property value?
0
 

Author Comment

by:replyanshu
ID: 24049192
yes looping through the columns
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 24049280
If you are just looping through the columns, they will be returned in the order they are defined.  If you want to check the display position with the DisplayIndex property.

Reference:

How to: Change the Order of Columns in the Windows Forms DataGridView Control
http://msdn.microsoft.com/en-us/library/wkfe535h.aspx
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Normally the drop down box control found in the .Net framework tools is able to select just one data and value at a time, which is displayed on the text area.   But what if you want to have multiple values to be selected in the drop down box? As …
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now