Hi All, I am Very New in Infragistics win Controls. How get the columns index same as display in Grid LayOut,
Even if some columns are hidden in between. Suppose i have 20 columns in Grid, and 5 to 15 columns visible false, so 16th columns position in Grid is 6. and i want to get 16th column index 6, How it is posible?
Hi Joe,
Yes, changing the VisiblePosition of a column may change the Index of that column. As a rule, you should not refer to a specific column by index, you should always use the key.
The Index may change, but the Key never will (unless you or your data source changes it).
Indices are great if you want to loop through all of the items in a collection and do something to all of them. But if you want one particular column, the key is a better choice.
Sorry I meant to say , if i now use the CellListSelect event and call e.Cell.Column.Index;
Will this return an index of 11 or 6? Currently i have an if statement to check if this column is selected.
if (e.Cell.Column.Index == Index)
// do something;
and if this e.Cell.Column.Index returns an index of 11, this if statement will never hit.
ThanksJoe
It works !! Thanks!!
I have one more question. Suppose I have a column names A, and to get this column index i use the following function:
int index = Grid.DisplayLayout.Bands[0].Columns["A"].Header.VisiblePosition;
Let's suppose further that function returns an index of 11. If I now use
Grid.DisplayLayout.Bands[0].Columns[
"A"].Header.VisiblePosition = 6 to move this column to position 7(zero index).
If I now re-use, index = Grid.DisplayLayout.Bands[0].Columns["A"].Header.VisiblePosition;
Will this return an index of 6 or 11? Is there a way to get the current column index?
Thanks
Joe
It depends what RowLayoutStyle you are using. But most of the time, you would do something like this:
this.ultraGrid1.DisplayLayout.Bands[0].Columns["column key"].Header.VisiblePosition = 0;
Of course, if your grid is bound to a data source at design-time, you can just click and drag the column headers on the design surface and put them where you want them.
In datagridview, if i want to display column 5 in position 1 i would do the following:
Datagrid[4].DisplayIndex = 0;
How do i do this with Infragistics control?