I am using UltraGrid for a data entry form as most of the KeyPunching guys demands that enter key must act like TAB key. I tried to achieve it with the help of following article. But still enter key is getting the cursor next column of the next row instead of next column of the same row, 2ndly at last column it must go to the next row, either to enter new record or on existing record for editing. I hope you got my point.
Thanks for all previous supports.
Regards AHK
All of this behavior is controlled by the KeyActionMappings of the grid. I really can't say exactly what you need to do to get the behavior you want. But what I would recommend is looping through the existing KeyActionMappings collection of the grid and displaying them. Look for mappings for the Tab key and see what they are doing. Also, make sure there are no mappings for the Enter key already in the list that you may not want. There are different mappings for moving to the next cell - for example, there's NextCell and NextCellByTab and they have different behavior. One might wrap to the next row while the other does not, so you wil need to check the documentation or experiment with these to see what they do.
Also, I'm pretty sure that the SamplesExplorer for the grid has a sample of KeyActionMappings that lists the existing ones and allows you to perform an action, so you can experiment and see what they do.
Thanks for the hint, i got the detail of KeyActionMapping, please help me further.
I want the enter key should work like tab but at the end of row .. (at the last col of the row) it should go to the next row. presently it goes to next row even if currently on 1st col of the row.
I've got the same problem too..
I've remove the keys.Enter mapping, and add new mapping for keys.Enter, but still not work.
Can you give me the code how to remove or replacing the keys.Enter so it's act like key.Tab
Thanks
I'm not that experienced with the keymapping part of the control since I haven't had the need for it yet, but wouldn't a command like this work:
ultraGrid1.KeyActionMappings.Add(new GridKeyActionMapping(Keys.Enter, UltraGridAction.NextCell, 0, UltraGridState.Cell, Infragistics.Win.SpecialKeys.All, 0));
When I placed this code into the load event of the form my enter key worked just like the tab key, so maybe it'll work for you too!
Still not work, Keys.Enter not work like Keys.Tab on TemplateAddRow
the cell move to the new row when i press Enter key on TemplateAddRow
Alright, hopefully with this suggestion it works. I'm the type that can't sleep if I find something challenging. I used a TemplateOnBottom. Here's what I came up with:
{
ugKam.Dispose();
}
ultraGrid1.PerformAction(UltraGridAction.NextCellByTab);
else
--This place seriously needs some code tags. Infragistics, you made my grid sexy, now make the forum sexy. :P
Wowww..great
it's work.. thank you very much.
have a nice day
Like Mike wrote you are under the TemplateAddRow and the ENTER key try to commit the changes, so you can use the code from tbetts1982 to change the ENTER map key
To make enter key act like tab
i used the following code:
Public Sub MakeEnterActLikeTab(ByVal Grid As Infragistics.Win.UltraWinGrid.UltraGrid) Dim newKam As Infragistics.Win.UltraWinGrid.GridKeyActionMapping For Each ugkam As Infragistics.Win.UltraWinGrid.GridKeyActionMapping In Grid.KeyActionMappings If ugkam.KeyCode = Keys.Tab Then newKam = New Infragistics.Win.UltraWinGrid.GridKeyActionMapping(Keys.Enter, ugkam.ActionCode, ugkam.StateDisallowed, ugkam.StateRequired, ugkam.SpecialKeysDisallowed, ugkam.SpecialKeysRequired) Grid.KeyActionMappings.Add(newKam) End If Next End Sub
and on lastcell of the grid when i press enter key it should move to next control (NextControlOnLastCell) ?
can you give sample code for this?