[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 696
  • Last Modified:

Capture keypressed event within Datagrid cell

i am displaying List box when ever the cursor in one of the cell of datagrid.Now i want to filter the listbox according to the key pressed inside the Datagrid.can i catch this event.
0
mahmood66
Asked:
mahmood66
  • 5
  • 2
1 Solution
 
sunithnairCommented:
You can use javascript to catch keypress. You can then implement the KeyPressEvent in javascript and postback to the server to filter the listbox


<input type="text" name="test" onkeypress="KeyPressEvent()">

Open in new window

0
 
mahmood66Author Commented:
how to use this can you give the complete code
0
 
mahmood66Author Commented:
dear i am using vb.net 2005 and  datagrid view control
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
planoczCommented:
"i want to filter the listbox according to the key pressed inside the Datagrid"
Can you give more detail of what you want?
Keypress from each cell? or Keypress from the listbox only?
0
 
mahmood66Author Commented:
ok i am i using datagrid in which i am displaying listbox on the click event of the cell as like a dropdown combo in the datagrid.now i want catch the keypress event inside the cell of the datagrid which will result in filtering the listbox accordingly.filtering is the next step .First i want to know whch letter is pressed on the keyboard by the user.
0
 
mahmood66Author Commented:
I hope everything is clear
0
 
mahmood66Author Commented:
no answer
0
 
planoczCommented:
Sorry I have been real busy.
here is a  piece of code that see's the keypress on the form.
I was using it for a Horz. Scroll movement.
All you have to do is change the code for the keys you want to search for.
I hope this will help you in your search for the listbox keypress group.
   Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean
        Const WM_KEYDOWN As Integer = &H100
        Const WM_SYSKEYDOWN As Integer = &H104
 
        If ((msg.Msg = WM_KEYDOWN) Or (msg.Msg = WM_SYSKEYDOWN)) Then
            Select Case (keyData)
                Case System.Windows.Forms.Keys.Home
                    Me.HBar.Value = 1
                Case System.Windows.Forms.Keys.End
                    Me.HBar.Value = Me.MaxRecordCount
                Case System.Windows.Forms.Keys.PageUp
                    If (Me.HBar.Value + 20) >= Me.MaxRecordCount Then
                        Me.HBar.Value = Me.MaxRecordCount
                    Else
                        Me.HBar.Value += 20
                    End If
                Case System.Windows.Forms.Keys.PageDown
                    If (Me.HBar.Value - 20) <= 1 Then
                        Me.HBar.Value = 1
                    Else
                        Me.HBar.Value -= 20
                    End If
                Case System.Windows.Forms.Keys.Right
                    If Me.HBar.Value = Me.MaxRecordCount Then
                    Else
                        Me.HBar.Value = Current_Row + 1
                    End If
                Case System.Windows.Forms.Keys.Left
                    If Me.HBar.Value = 1 Then
                    Else
                        Me.HBar.Value = Current_Row - 1
                    End If
                Case System.Windows.Forms.Keys.Up
                    If (Me.HBar.Value + 5) >= Me.MaxRecordCount Then
                        Me.HBar.Value = Me.MaxRecordCount
                    Else
                        Me.HBar.Value += 5
                    End If
                Case System.Windows.Forms.Keys.Down
                    If (Me.HBar.Value - 5) <= 1 Then
                        Me.HBar.Value = 1
                    Else
                        Me.HBar.Value -= 5
                    End If
            End Select
            Current_Row = Me.HBar.Value
        End If
    Return MyBase.ProcessCmdKey(msg, keyData)
    End Function

Open in new window

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now