Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / January 2008

Tip: Looking for answers? Try searching our database.

DataGridView column DisplayIndex problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Aleksey Timonin - 10 Jan 2008 14:09 GMT
Hi guys,
I try to adjust columns order in DataGridView via DisplayIndex property and
it doesn't work me properly. Here is the code:

protected override void AdjustGridColumns() {
   foreach (DataGridViewColumn clmn in _grdCustomizations.Columns)
       clmn.Visible = false;
   AdjustColumn("name", "View Customization");
   AdjustColumn("userID", "User ID");
   AdjustColumn("machineID", "Machine ID");
   AdjustColumn("resolutionID", "Resolution ID");
   AdjustColumn("createdOn", "Created On");
   AdjustColumn("modifiedOn", "Modified On");
}

private void AdjustColumn(string name, string displayName){
   DataGridViewColumn clmn = _grdCustomizations.Columns[name];
   clmn.HeaderText = displayName;
   clmn.Visible = true;
   clmn.DisplayIndex = _grdCustomizations.Columns.Count - 1;
}

After I call AdjustGridColumns method it shows me the next columns order :

ID (that shoudn't be at all)
View Customization
Created On
Modified On
User ID
Machine ID
Resolution ID

So, what don't I right? Why the "ID" still visible? Why order of columns
doesn't right?

Thanks a lot
Jack Jackson - 10 Jan 2008 17:14 GMT
>Hi guys,
>I try to adjust columns order in DataGridView via DisplayIndex property and
[quoted text clipped - 32 lines]
>
>Thanks a lot

It looks to me like you set DisplayIndex for the 6 columns that you
call AdjustColumn for to the same value.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.