Hi all,
I have a new task that need to display out a report in grid with few column of data, then allow user direct fill in the data like using excel. the grid should be able to move to next cell by clicking the arrow keys in keyboard, and user can direct key-in the value. May I know is it any function of infragistic able to customize like this?
Please guide.
Thank you very much!
Hi,
This KB article should help you achieve what you want with the arrow keys:
HOWTO:UltraWinGrid Cursor Movement like Excel
Hi Mike,
Thanks for your useful information. Currently my project is written in C#, so I guess it will be very helpful that if you can provide me any sample available in C#.
Here's the important part of that HOWTO converted over to C#.
private void ultraGrid1_KeyDown(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.Up: ultraGrid1.PerformAction(UltraGridAction.ExitEditMode, false, false); ultraGrid1.PerformAction(UltraGridAction.AboveCell, false, false); e.Handled = true; ultraGrid1.PerformAction(UltraGridAction.EnterEditMode, false, false); break; case Keys.Down: ultraGrid1.PerformAction(UltraGridAction.ExitEditMode, false, false); ultraGrid1.PerformAction(UltraGridAction.BelowCell, false, false); e.Handled = true; ultraGrid1.PerformAction(UltraGridAction.EnterEditMode, false, false); break; case Keys.Right: ultraGrid1.PerformAction(UltraGridAction.ExitEditMode, false, false); ultraGrid1.PerformAction(UltraGridAction.NextCellByTab, false, false); e.Handled = true; ultraGrid1.PerformAction(UltraGridAction.EnterEditMode, false, false); break; case Keys.Left: ultraGrid1.PerformAction(UltraGridAction.ExitEditMode, false, false); ultraGrid1.PerformAction(UltraGridAction.PrevCellByTab, false, false); e.Handled = true; ultraGrid1.PerformAction(UltraGridAction.EnterEditMode, false, false); break; } }
The above code shows you how to handle the KeyDown event of the UltraGrid to get that Excel style arrow key navigation.
if set the column ValueList, the data changes in the cell after passing through it.
In a case like this, your EditingControl will be receiving the key message for the arrow key.
So you have to do something similar on your EditingControl that you are doing with the grid here. Trap keydown and watch for the arrow keys and then you can call the same PerformAction methods on the grid that you are using in this case.
If you don't want to write code in your EditingControl that is specific to the grid and you need a more generic solution, you could try to simulate the Tab key by calling SelectNextControl or using SendKeys.
I have implemented the excel like navigation as described above. I am using a UltraControlContainerEditor for the editor of a column in my grid. Once I navigate to this column using the arrow keys I cant navigate away using the arrow keys. It seems as though the key press event is not firing for the grid while the editor has focus, most likely because it is being handled by the editor embedded inside the cell. Is there anyway to achieve this arrow navigation with UCC editors? Maybe some property on UCC editor that will pass key events to the grid.
Thanks in advance!
Hi Boris!!
This is neat!! Clean!! WORKS!!! I was going to try to do something using ActiveScrollRegion per the suggestion of one of the other posts...
ThanksChitra
Hello Chitra,
Thank you for your patience!
Here is how I was able to achieve it:
private void ultraGrid1_KeyDown(object sender, KeyEventArgs e) { UltraGridCell oldIndex = null;
switch (e.KeyCode) { case Keys.Up: oldIndex = ultraGrid1.ActiveCell; ultraGrid1.PerformAction(UltraGridAction.ExitEditMode, false, false); ultraGrid1.PerformAction(UltraGridAction.AboveRow, false, false); ultraGrid1.ActiveCell = ultraGrid1.ActiveRow.Cells[oldIndex.Column]; e.Handled = true; ultraGrid1.PerformAction(UltraGridAction.EnterEditMode, false, false); break; case Keys.Down: oldIndex = ultraGrid1.ActiveCell; ultraGrid1.PerformAction(UltraGridAction.ExitEditMode, false, false); ultraGrid1.PerformAction(UltraGridAction.BelowRow, false, false); ultraGrid1.ActiveCell = ultraGrid1.ActiveRow.Cells[oldIndex.Column]; e.Handled = true; ultraGrid1.PerformAction(UltraGridAction.EnterEditMode, false, false); break; case Keys.Right: ultraGrid1.PerformAction(UltraGridAction.ExitEditMode, false, false); ultraGrid1.PerformAction(UltraGridAction.NextCellByTab, false, false); e.Handled = true; ultraGrid1.PerformAction(UltraGridAction.EnterEditMode, false, false); break; case Keys.Left: ultraGrid1.PerformAction(UltraGridAction.ExitEditMode, false, false); ultraGrid1.PerformAction(UltraGridAction.PrevCellByTab, false, false); e.Handled = true; ultraGrid1.PerformAction(UltraGridAction.EnterEditMode, false, false); break; }
}
Please feel free to let me know if a question about our toolset comes up on your mind.