Hi,
If somebody could help me determine how to find the current column position of an active cell in contrast to the DataTable or visible/displayed grid.
I found how to get the current row of the activated cell, which is "ultragrid.ActiveCell.Row.VisibleIndex". So I was assuming that I could find the columns in "ultragrid.ActiveCell.Columns" but unfortunately I could not find a particular property that will return it.
Thanks,
Aaron
Hi Aaron,
The visible position of a column is not necessarily straightforward, because of RowLayouts. If you are not using RowLayouts, then you can use cell.Column.Header.VisiblePosition.
Hi Mike,
I want to get the selected column header name. for this i need selected column index of that grid.
Please check my following code.
Infragistics.Win.UIElement aUIElement;
aUIElement = ultraGrid1.DisplayLayout.UIElement.ElementFromPoint(new Point(e.X, e.Y));
UltraGridRow tRow;
UltraGridColumn tCol;
tCol = (UltraGridColumn)aUIElement.GetContext(typeof(UltraGridColumn));
tRow = (UltraGridRow)aUIElement.GetContext(typeof(UltraGridRow));
in tRow i am getting the row and index whereas in tCol always nothing when i click on column header. But if i select in grid data then i am getting value in tCol(column index).
But the problem is i need to get column header name.
Ravi
itsguntus said: tCol = (UltraGridColumn)aUIElement.GetContext(typeof(UltraGridColumn)); tRow = (UltraGridRow)aUIElement.GetContext(typeof(UltraGridRow)); in tRow i am getting the row and index whereas in tCol always nothing when i click on column header. But if i select in grid data then i am getting value in tCol(column index).
The column header UIElement probably doesn't have a context of the column, then. In that case, you probably have to get a context of the ColumnHeader and use the Column property on that.
Hey Mike,
Something went really weird.... I am binding the grid to a constant datatable. This grid has a Column chooser. Let's say I have 5 columns and 3 rows, and I am currently in row 1 column 4. When I retrieve the ActiveCell.Column.Header.VisiblePosition, it returns me a 6... and then something worse happened, as I added columns and removed some. Now I have 7 columns and still 3 rows. Assuming I am in the 6th column, when I retrieve the ActiveCell.Column.Header.VisiblePosition again, it returned me a 9...
Now from the first call to the second call, the difference from the actual column being activated and returned by the function changed. Is this a bug, or I am doing something wrong...
I'm not sure. But the VisiblePosition property need not necessarily be contiguous. For example, it would be perfectly valid to have three columns with VisiblePositions of 1, 50, and 100.
The grid doesn't do that by itself, of course, and if you move a column in the grid, they will probably get re-numbered to 0, 1, and 2.
But it's impossible for me to guess why that's happening with the information at hand.
Is there a way to manually set it? I tried doing:
for each row in the ultragrid get a count
ultragrid.rows[count].cells[col].column.header.visibleposition = something
It doesn't seem to set the activecell.column.header.visibleposition to the way I want it to be, any suggestions?
I was facing the same problem, I would like to set the active cell in a wingrid that consists of two bands.
I found this thread and here is what I did.
Dim row as UltragrirdRow = wingrid.ActiveRow
Dim cell as UltragridCell = wingrid.ActiveCell
The above is use to keep which row and which cell that was activated.
-------------------------------------------
Then I have the below codes to set the active mouse cursor.
wingrid.ActiveRow= row
wingrid. ActiveCell=cell
wingrid.PerformAction(UltragridAction.EnterEditMode)
Thanks mike, that was the easiest way to do about it. Works great now.
This code doesn't make a lot of sense. If you want to get the columns in the band, you should use something like this:
grid.DisplayLayout.Bands[band key].Columns[column key].Header.VisiblePosition = x
Using the row to get a cell to get back to the column is a really roundabout way to do it.
Also, when you set the VisiblePosition on the columns, you need to do it in order, because otherwise, it will be unpredictable. What I mean is.. you should assign the column you want in position 0 first, then position 1, then position 2. If you do it out of order and assign a column to position 5, for example, and then another column to position 4, the second column may change the position of the first one.