Hi all,
i am using ultra grid. i need to check whether active cell is last column of ultragrid or not. please help out for this
Hello Gurumurthy,
In case you are showing only 5 columns, what can I suggest you is using the VisiblePosition property if you want to access the last column and check if the index of the column that corresponds to the active cell is equal to 4 (the index starts from 0). The code could be changed like this:
if (cell != null && cell.Column.Header.VisiblePosition == 4)
If you want to access a specific column and the user is able to move the columns, I suggest you using the column key instead, since when the column is moved its VisiblePosition property changes based on where the column is placed. The code below is similar to the example above but uses the Key property instead:
if (cell != null && cell.Column.Key.Equals("LastVisibleColumn"))
Please let me know if you have any questions.
Regards, Ivan Kitanov
thanks for the reply ivan
Actually in grid datasource contains 59 columns. but I am showing only 5 column for index mismatch happening
In order to access the active cell of the grid, you can use the ActiveCell property, which will return or set the active cell of the grid. After that, its column index should be checked if it is equal to the index of the last column, the code should look similar to this:
var cell = this.ultraGrid1.ActiveCell;
if (cell != null && cell.Column.Index == this.ultraGrid1.DisplayLayout.Bands[0].Columns.Count - 1)
{
//your custom logic
}