Solved

Datagridview column reorder problem

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

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…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

862 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

25 Experts available now in Live!

Get 1:1 Help Now