Main Menu
Knowledge Base
Product Registration
Log an Incident
Request a Feature
Search Incidents/Bug Reports


Search KB

Please note: In an effort to better serve you, we are in the process of restructuring DevCenter. In the process, we have moved many items that you may be used to finding in DevCenter over to the Main Site. If you are having trouble locating something, please try looking at the following places:

Knowledge Base Article: KB02028

HOWTO:How can I make the UltraWinGrid respond to the ENTER key the same way it does to the TAB key?


The information in this article applies to:
UltraWinGrid (v1.0.5005)
  Article Created: 
8/5/2002

Last Updated:
10/19/2005

Article Type
How To
  
Page Options
Average Rating:
7 out of 10

Rate this page
Print this page
E-mail this page
Add to Favorites

Summary

All the keyboard behavior of the grid is determined by the KeyActionMappings collection. This collection can be modified to alter the keyboard behavor. By default, the collection already contains definitions for Tab key behavior. So in order to make the grid respond to Enter, all that must be done is to go through the KeyActionMappings and add a corresponding mapping for the Enter key that matches each Tab key entry.

Additional Information

The following sample code loops through all the KeyActionMappings in the grid. Whenever if finds a KeyActionMapping for the Tab key, it creates a copy of the mapping that applies to the Enter key, instead of tab and adds it to the collection.

In VB.NET:

Private 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

In C#:

private void MakeEnterActLikeTab(Infragistics.Win.UltraWinGrid.UltraGrid Grid)
{
    Infragistics.Win.UltraWinGrid.GridKeyActionMapping newKam;

    foreach (Infragistics.Win.UltraWinGrid.GridKeyActionMapping ugKam in Grid.KeyActionMappings)
    {
        if (ugKam.KeyCode == Keys.Tab)
        {
            newKam = new Infragistics.Win.UltraWinGrid.GridKeyActionMapping(Keys.Enter, ugKam.ActionCode, ugKam.StateDisallowed, ugKam.StateRequired, ugKam.SpecialKeysDisallowed, ugKam.SpecialKeysRequired);
            Grid.KeyActionMappings.Add(newKam);
        }
    }
}


How would you rate the quality of this content?
Poor -----------------------------------------> Outstanding

Tell us why you rated the content this way. (optional)