Reputation: 11
gv = (GridView)emgrid.MainView;
//for testing
gv.Columns[1].Caption = "hello";
string caption = gv.Columns[1].Caption;
gv.Columns[1].VisibleIndex = 10;
int visibleindex = gv.Columns[1].VisibleIndex;
caption is changed into "hello" but the visibleindex changed into 9 not 10.
Why and how to solve,Thanks
Upvotes: 0
Views: 1411
Reputation: 13426
I suppose that gv.Columns[1].VisibleIndex
was lower than 10 before the assignment. If so, then this kind of behavior is documented for GridColumn.VisibleIndex
:
When you move a column forward (i.e., assign a new visible index that is higher than the current visible index), the current column is moved to the position before the column whose VisibleIndex equals the assigned value. So, the actual visible index will be the assigned value minus one. ...
So for forward moved VisibleIndex = 10;
unintuitively sets VisibleIndex
to 9. You'll need to pass 11 to set it to 10.
Upvotes: 1