Results 1 to 7 of 7

Thread: [RESOLVED] Datagridview Column Order Problem

  1. #1

    Thread Starter
    Member Cyrax.NET's Avatar
    Join Date
    Feb 2007
    Posts
    54

    Resolved [RESOLVED] Datagridview Column Order Problem

    Problem: I have a DGV. It has some columns. The columns are in the correct order e.g. 1,2,3,4 at design time.

    When I start debugging and then come back to VS, the order of the columns have changed and I have to put them back in the correct order everytime. There about 10 columns so it gets very annoying!

    After some testing I have realised it only occurs if
    1) I make a change on the form that holds the DGV
    2)Leave the form open in VS while I play the application ie. debug

    I dont think there is a solution to this but I am hoping is someone can tell me of any options to forice VS not to alter my code or any reasons why VS is reordering my columns on its own accord?

    Thanks in advance.
    Please mark your thread as Resolved; it helps identify which posters still require assistance and keeps things nice & tidy
    Acknowledge a helpful post; keeps the community going

  2. #2
    Frenzied Member
    Join Date
    Jan 2010
    Location
    Connecticut
    Posts
    1,687

    Re: Datagridview Column Order Problem

    Step through the program to see where (if it is consistent) it changes the columns. That will give you more information (if it is inconsistent, that is still information, but not as helpful).
    VB6 Library

    If I helped you then please help me and rate my post!
    If you solved your problem, then please mark the post resolved

  3. #3

    Thread Starter
    Member Cyrax.NET's Avatar
    Join Date
    Feb 2007
    Posts
    54

    Re: Datagridview Column Order Problem

    Yes I would ofcourse tried this but the problem is when I am debugging i.e. running the application, the column order is correct. It is only when I exit the application that the order has changed.

    I don't think there is a trace that debugs the application while running and while in design time. If there is then I'd be
    Please mark your thread as Resolved; it helps identify which posters still require assistance and keeps things nice & tidy
    Acknowledge a helpful post; keeps the community going

  4. #4
    Frenzied Member
    Join Date
    Jan 2010
    Location
    Connecticut
    Posts
    1,687

    Re: Datagridview Column Order Problem

    Does this happen every time? For example if you press F5 (or click run) but do not do anything and immediately click stop, does it happen then? If you must do something then set your app up so you do not have to do anything. This will help you determine what is causing it. You can also make a new form, add a grid, add columns and see if it happens there.

    A fix that doesn't solve the problem would be to set the columns in code, a preferred method anyway.

    Try the above steps and post your results so we can narrow it down.
    VB6 Library

    If I helped you then please help me and rate my post!
    If you solved your problem, then please mark the post resolved

  5. #5
    New Member
    Join Date
    Oct 2013
    Posts
    1

    Re: Datagridview Column Order Problem

    I set the order in code. Use the UI to create and place the DataGridView. Once in code,

    dgvCustomers.Column("FName").DisplayIndex = 0
    dgvCustomers.Column("LName").DisplayIndex = 1

    Then the problem becomes that the order does not always work. The following article explain how to fix that:

    http://www.internetworkconsulting.ne...er-not-working

  6. #6
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Datagridview Column Order Problem

    It is only when I exit the application that the order has changed.
    And if you don't mess about changing the order in the meantime what happens if you run the program again? And again? And again? If the columns are in the correct order every time the program runs irrespective then I'm really not sure why you have a problem with it!

    In any case, how do you expect us to answer such a problem without benefit of code related to DGV, the design time properties or even a screen capture of the DGV at its various stages. We're just blundering about in the dark at the moment.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  7. #7

    Thread Starter
    Member Cyrax.NET's Avatar
    Join Date
    Feb 2007
    Posts
    54

    Re: Datagridview Column Order Problem

    Quote Originally Posted by dunfiddlin View Post
    And if you don't mess about changing the order in the meantime what happens if you run the program again? And again? And again? If the columns are in the correct order every time the program runs irrespective then I'm really not sure why you have a problem with it!
    If the column order was OK everytime I would not have posted. I was not changing the order, in-code or using the UI. The design-time column order of the DGV was different after debugging to what it was before I had played the application. i.e. on-screen design time order - 1,2,3,4 >>> Debug/play the application >>> Do nothing/close the app >>> on-screen design time order 3,1,4,2.

    In any case, how do you expect us to answer such a problem without benefit of code related to DGV, the design time properties or even a screen capture of the DGV at its various stages. We're just blundering about in the dark at the moment.
    You're only 3 years to late so I am not expecting you to do anything.
    The reason I did not post any code was because the problem was only occurring at design time. Run-time code would not have affected this. I would of provided screenshots and code should someone answering the question have asked.

    I put it down to my project solution files and VS2008 as it didn't occur in 2010. Closed.
    Please mark your thread as Resolved; it helps identify which posters still require assistance and keeps things nice & tidy
    Acknowledge a helpful post; keeps the community going

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width