Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2265
Search DropDown when Key Pressed on selected cell in grid
posted

Hi,

I want to be able to allow a user to press a key on the grid and forward the key press to the cell that contains a drop down/drop down list.  On doing this I want it to automatically select the first entry that matches.  Is there any way to do this?

I set grid to only select a cell when it is clicked in InitializeLayout as follows:

.Layout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.CellSelect

I am currently only doing this for a text box as Boris has suggested in a previous post, but I thought I'd start a new thread for this one as it is slightly different.

I have the following to allow this for a text box.

Private fired As Boolean = False
    Private keyPressed As String = String.Empty
 
    Private Sub MyGrid_KeyUp(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles ui_ugWelds.KeyUp
        With MyGrid
            If .ActiveCell.IsInEditMode And (e.KeyCode = Keys.Enter Or e.KeyCode = Keys.Return) Then
                .PerformAction(UltraWinGrid.UltraGridAction.ExitEditMode, False, False)
 
            ElseIf Not .ActiveCell.IsInEditMode And UIHelper.IsValidEditorCharacter(e) Then
                keyPressed = UIHelper.GetChar(e)
                fired = True
                .PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode)
 
            ElseIf e.KeyCode = Keys.Escape Then
                .ActiveCell.Value = .ActiveCell.OriginalValue
                .PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.UndoCell)
            End If
        End With
    End Sub
 
    Private Sub MyGrid_AfterEnterEditMode(sender As System.Object, e As System.EventArgs) Handles ui_ugWelds.AfterEnterEditMode
        If fired Then
            With MyGrid
                If Not .ActiveCell.EditorResolved.SupportsDropDown Then
                    .ActiveCell.Value = keyPressed
                    If .ActiveCell.Value IsNot Nothing AndAlso .ActiveCell.EditorResolved.SupportsSelectableText Then
                        .ActiveCell.SelStart = .ActiveCell.Value.ToString().Length
                    End If
                End If
            End With
        End If
        fired = False
    End Sub 

 

Thanks

Andez