When a user tabs onto an Ultragrid control (that has no current selection) from any other control, the focus goes to the first row. I do not like this. How can I make the focus go to the first cell instead?
Setting grd.DisplayLayout.TabNavigation = Infragistics.Win.UltraWinGrid.TabNavigation.NextCell does not seem to have any effect on this scenario. Basically, I do not want rows to be tabstops, but rows don't appear to have that property.
-Ben
private void ultraGrid1_Enter(object sender, EventArgs e) { UltraGrid grid = (UltraGrid)sender; if (grid.ActiveCell == null && grid.Rows.Count > 0) { UltraGridColumn firstColumn = grid.DisplayLayout.Bands[0].GetFirstVisibleCol(grid.ActiveColScrollRegion, false, true); if (firstColumn != null) { grid.Rows[0].Cells[firstColumn].Activate(); grid.PerformAction(UltraGridAction.EnterEditMode, false, false); } } }
Thanks for the quick response Mike. That (mostly) worked. The call to .GetFirstVisibleCol does not seem to work properly. The second argument for includeNonActivateable has no effect. My first column is always disabled and it still returns that disabled column. No big deal as I just don't use that call and just force it to the first column that I know is enabled. But you might want to look into that. I'm using 2009.2 WinForms.
How are you disabling the first column? It should work if you are setting the CellActivation property on the column. But if you are setting the Activation on each cell within that column, it won't work, since it won't have any way of knowing that they are all disabled.
Indeed, I am setting the CellActivation property of the column exactly as follows:
grdPresets.DisplayLayout.Bands[0].Columns[PG_COL_PB_NUMBERS].CellActivation = UltraWinGrid.Activation.Disabled;
Hm, that's odd. I took a look at the GetFirstVisibleCol method source code and it looks like the includeNonActivateable refers to the column header, not the cells.
So I guess what you would have to do is, get the first visible column, then check the CellActivation property (and also possibly the TabStop property) and then loop through the columns using GetRelatedVisibleColumn until you find one that can be activated. That is, of course, if you want a generic solution. If you know to always skip the first column and you are not letting the user moves the columns around, then you can just do that. :)