Solved

Datagridview column reorder problem

Posted on 2009-03-31
5
526 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Replace &lt; with < 14 59
C# HTTP GET method sample code 3 57
Help with adding data element is a specific row of an xml file using VB.NET 4 27
C# Gridview 1 32
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

773 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