We have a solution where we need be able to only tab between editable cells in a grid. The default behavior of the tab is to select the next cell in the grid. Is there any way to override this, so that clicking tab the grid will select the next editable cell in the grid?
Regards
Bjarne
Thanks for the code, but I don't get it to work. I have slightly different scenario because I have grouped grid but I think it should work with this kind of code. I have simplified it a bit.
RowBase row = EntryGrid.ActiveCell.Row; int currIndex = 0; if (IS TO BE SKIPPED) { foreach (Cell cell in row.Cells) { if (cell.IsActive) { if ((row.Cells.Count - 1) > currIndex) { row.Cells[currIndex + 1].IsActive = true; row.Cells[currIndex + 1].IsSelected = true; return; } return; } currIndex++; } }
The problem is that after I've changed the IsActive to true for the next cell, something changes it back to the previous. My callstack just says it's external code before coming again to ActiveCellChanged (of course it comes there once after the first change). I've removed all the other code related to my Grid to eliminate other causes for this kind of behaviour. Should the IsActive be set to False first before setting it to true for other column? Any other ideas?
Here's one way to achieve the skipping of cells. It uses the ActiveCellChanged event of the XamGrid. Some further work could be done to improve it.
void theGrid_ActiveCellChanged(object sender, EventArgs e) { int currindex = 0; if (YOUR LOGIC HERE COMPARING IF THE CELL SHOULD BE SKIPPED) { foreach (Infragistics.Controls.Grids.Cell cell in theGrid.ActiveCell.Row.Cells) { if (cell.IsActive) { if ((theGrid.Rows[theGrid.ActiveCell.Row.Index].Cells.Count - 1) > currindex) { theGrid.Rows[theGrid.ActiveCell.Row.Index].Cells[currindex + 1].IsActive = true; theGrid.Rows[theGrid.ActiveCell.Row.Index].Cells[currindex + 1].IsSelected = true; return; } else { if ((theGrid.Rows.Count - 1) >= theGrid.ActiveCell.Row.Index) return; theGrid.Rows[theGrid.ActiveCell.Row.Index + 1].Cells[0].IsActive = true; theGrid.Rows[theGrid.ActiveCell.Row.Index].Cells[currindex + 1].IsSelected = true; return; } } currindex++; } } }
I'm also in need of this feature. I have pretty similar use case with micheltetreault. Some cells are disabled in my use case and I would like the tab navigation to skip those cells as well.
I'm using a Style to disable the cells and I tried to set the IsTabStopProperty to false in the same style but that didn't work. My Style is typeof(CellControl).
So there's just no way to achieve this type of functionality? Maybe you could turn this into a feature request so it is at least considered for the future versions?
Here's a concrete example where it would be quite useful :
I use a XamGrid to display financial data (revenues and expenses). The grid has three columns : "description", "current_year", "next_year". The first column is a TemplateColumn and displays a predefined description ("rent", "taxes", etc) using a TextBlock, but there are cases where there is also a TextBox (eg : "Other. Please specify : [TextBox here]). The two other columns contain a XamNumericEditor to enter amounts.
In that case, I would like the TAB key to browse only through cells where you can actually type something, thus only cells of the 2nd and 3rd column and cells of the 1st column if it is a "Other. Please specify : " case.
It would be useful if we could trap the TAB event and allow to specify that we want to skip to the next cell.
Hi,
Nothing has been added for this. We put out a request for more information on what the exact use case is that would be liked to be achieved, but we haven't gotten anything back.
Could you provide us your scenario?
Thanks,
-SteveZ