DataGridViewColumn DisplayIndex Issue

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • news.microsoft.com

    #1

    DataGridViewColumn DisplayIndex Issue

    Hello..

    I'm having an issue setting the DisplayIndex for my DataGridViewCol umns

    The dataViewGrid is bound to a class derived from List<T>

    I'm doing something like:

    myDataViewGrid. Columns["A"].DisplayIndex = 0
    myDataViewGrid. Columns["B"].DisplayIndex = 1
    myDataViewGrid. Columns["C"].DisplayIndex = 2
    myDataViewGrid. Columns["D"].DisplayIndex = 3
    .... there are several other columns, but I don't care about their position.

    Which ever is the last column I set, that seems to be the one that sticks...
    looking at the intermediate results by looking at the names and
    DisplayIndexes, I see something like this:

    After setting A:0
    1 F
    2 G
    3 D
    4 E
    5 B
    0 A
    6 C
    7 etc..
    ...
    ...

    After setting B:1
    0 F
    2 G
    3 D
    4 E
    1 B
    5 A
    6 C
    7 etc..
    ...
    ...

    After setting C:2
    0 F
    1 G
    3 D
    4 E
    5 B
    6 A
    2 C
    7 etc..
    ...
    ...


    I finally gave up, and move my set code to set ALL the column indexes,
    starting hightest index to lowest, and did this in the
    dataGridView2_D ataBindingCompl ete event reactor.

    Is this normal?


Working...