This is a migrated thread and some comments may be shown as answers.

Form level hot keys fired

11 Answers 109 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rajesh
Top achievements
Rank 1
Rajesh asked on 05 Jun 2012, 11:34 AM
Hi ,

I am facing one issue when I am trying to select item from grid dropdown for example

1. I have one dropdown in grid and having four items let say
     SName
     PName
     QName
     ZName
2.On my form(windows), I have a button(&Save) with hotkey S.
3.Now when I click on dropdown cell  and press key "S" to select item starting from "S", ideally it should select SName but it is firing Save Event(Alt + S) of form and this is the issue?
4.I have set Me(form).KeyPreview = True.

Need your help.

Thanks,
Rajesh Kumar

11 Answers, 1 is accepted

Sort by
0
Svett
Telerik team
answered on 06 Jun 2012, 04:21 PM
Hi Rajesh,

I answered to your question in the support ticket that you have already opened.

Please see our answer there for more information.

We kindly ask you to use just one support channel to contact us. Posting the same questions more than once slows down our response time, because we will need to review and address two or more tickets instead of one. Moreover, support threads are handled according to license and time of posting, so if it is an urgent issue, we suggest that you use a support ticket, which would be handled before a forum thread.

Thank you for your understanding.

Greetings,
Svett
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
0
Seth
Top achievements
Rank 1
answered on 21 Aug 2013, 01:17 PM
I'm having the same issue with the form level hotkeys firing. What was the solution?
0
George
Telerik team
answered on 23 Aug 2013, 01:49 PM
Hi Seth,

Thank you for writing.

Last time we could not reproduce the issue Rajesh described. I tried to reproduce it once again but with no avail. Since this seems to be rarely occurring issue I would like to kindly ask you to provide me with a sample project where the problem can be reproduced together with the exact steps that I need to take in order to reproduce it.

Thank you for your cooperation.
 
Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Seth
Top achievements
Rank 1
answered on 23 Aug 2013, 02:31 PM

I created a simple example that shows the issue. The form has two buttons with hotkeys and a RadGridView control. When you type the character for one of the hotkeys the click event fires and displays a message box. I am using Visual Studio 2010 and version 2010.1.321.40 of the grid. Let me know if you have any questions.

Designer code:

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
    Inherits System.Windows.Forms.Form
 
    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub
 
    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer
 
    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer. 
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.RadGridView1 = New Telerik.WinControls.UI.RadGridView()
        Me.Button1 = New System.Windows.Forms.Button()
        Me.Button2 = New System.Windows.Forms.Button()
        CType(Me.RadGridView1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'RadGridView1
        '
        Me.RadGridView1.Location = New System.Drawing.Point(51, 102)
        Me.RadGridView1.Name = "RadGridView1"
        Me.RadGridView1.Size = New System.Drawing.Size(494, 287)
        Me.RadGridView1.TabIndex = 0
        Me.RadGridView1.Text = "RadGridView1"
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(454, 33)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(75, 23)
        Me.Button1.TabIndex = 2
        Me.Button1.Text = "S&earch"
        Me.Button1.UseVisualStyleBackColor = True
        '
        'Button2
        '
        Me.Button2.Location = New System.Drawing.Point(454, 62)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(75, 23)
        Me.Button2.TabIndex = 3
        Me.Button2.Text = "E&xit"
        Me.Button2.UseVisualStyleBackColor = True
        '
        'Form1
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(593, 421)
        Me.Controls.Add(Me.Button2)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.RadGridView1)
        Me.Name = "Form1"
        Me.Text = "Form1"
        CType(Me.RadGridView1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)
 
    End Sub
    Friend WithEvents RadGridView1 As Telerik.WinControls.UI.RadGridView
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Button2 As System.Windows.Forms.Button
 
End Class



Form Code:

Public Class Form1
    Private Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
        MsgBox("Search")
    End Sub
 
    Private Sub Button2_Click(sender As Object, e As System.EventArgs) Handles Button2.Click
        MsgBox("Exit")
    End Sub
End Class
0
George
Telerik team
answered on 27 Aug 2013, 01:30 PM
Hi Seth,

Thank you for writing back.

I can confirm that this issue exists in version 2010 Q1 321 however it was fixed and is working properly in our latest release. That is why I would recommend you to upgrade to version 2013 Q2 724.

Alternatively you can check if the alt key is being held inside the event handler:
Private Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
    If ModifierKeys = Keys.Alt Then
        MsgBox("Search")
    End If
End Sub

I hope this helps.
 
Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Jose
Top achievements
Rank 1
answered on 06 Jan 2014, 05:05 PM
I am a coworker with Seth…  I downloaded the latest version (v.2013.3.1127.40 Trial) and still getting the same result.    Also the code example you sent Seth only partially handles the command button firing.  It does not address the fact that the keypress is not picked up or used in the grid.  

Thanks
Jose.

To move things along i've included code for a simple form.

 

Imports Telerik.WinControls.UI

Public Class Form1

    
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        RadGridView1.Columns.Add("UOM")

        Dim dt As New DataTable
        dt.Columns.Add("UOM")
        dt.Columns.Add("PKGTYPEDS")

        dt.Rows.Add("1", "ABROWN1")
        dt.Rows.Add("2", "ABROWN3")
        dt.Rows.Add("3", "ABROWN4")
        dt.Rows.Add("4", "ABROWN2")
        dt.Rows.Add("5", "BROWN1")
        dt.Rows.Add("6", "BROWN2")
        dt.Rows.Add("7", "BROWN3")
        dt.Rows.Add("8", "BROWN4")
        dt.Rows.Add("9", "UBROWN1")
        dt.Rows.Add("10", "UBROWN2")
        dt.Rows.Add("11", "UBROWN3")
        dt.Rows.Add("12", "UBROWN4")

        Dim colPKGUOM As GridViewComboBoxColumn = New GridViewComboBoxColumn()
        colPKGUOM.DataSource = dt.Copy
        colPKGUOM.DisplayMember = "PKGTYPEDS"
        colPKGUOM.ValueMember = "UOM"
        colPKGUOM.FieldName = "PKGTYPEDS"
        colPKGUOM.HeaderText = "Pkg Type"
        colPKGUOM.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList
        colPKGUOM.AutoCompleteMode = AutoCompleteMode.SuggestAppend
        RadGridView1.Columns.Insert(1, colPKGUOM)

        RadGridView1.Columns(0).Width = 300
        RadGridView1.Columns(1).Width = 300
        RadGridView1.AllowAddNewRow = True
    End Sub

    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
         MsgBox("Button2 Clicked")
    End Sub

    Private Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
        MsgBox("Button1 Clicked")
    End Sub

 
End Class

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer. 
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.Button1 = New System.Windows.Forms.Button()
        Me.Button2 = New System.Windows.Forms.Button()
        Me.RadGridView1 = New Telerik.WinControls.UI.RadGridView()
        CType(Me.RadGridView1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(609, 67)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(75, 23)
        Me.Button1.TabIndex = 0
        Me.Button1.Text = "&Button1"
        Me.Button1.UseVisualStyleBackColor = True
        '
        'Button2
        '
        Me.Button2.Location = New System.Drawing.Point(609, 26)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(75, 23)
        Me.Button2.TabIndex = 1
        Me.Button2.Text = "B&utton2"
        Me.Button2.UseVisualStyleBackColor = True
        '
        'RadGridView1
        '
        Me.RadGridView1.Location = New System.Drawing.Point(51, 154)
        Me.RadGridView1.Name = "RadGridView1"
        Me.RadGridView1.Size = New System.Drawing.Size(632, 127)
        Me.RadGridView1.TabIndex = 2
        Me.RadGridView1.Text = "RadGridView1"
        '
        'Form1
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(718, 502)
        Me.Controls.Add(Me.RadGridView1)
        Me.Controls.Add(Me.Button2)
        Me.Controls.Add(Me.Button1)
        Me.Name = "Form1"
        Me.Text = "Form1"
        CType(Me.RadGridView1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Button2 As System.Windows.Forms.Button
    Friend WithEvents RadGridView1 As Telerik.WinControls.UI.RadGridView

End Class

0
George
Telerik team
answered on 09 Jan 2014, 09:33 AM
Hi Jose,

Thank you for contacting us.

Can you please elaborate your problem a bit more? It appears that the buttons you are using on the form are the standard .NET buttons. I would also like to ask you to elaborate the part where you are saying "It does not address the fact that the keypress is not picked up or used in the grid". If you mean that when the grid is focused the buttons cannot be clicked using the shortcut keys (holding Alt and the corresponding letter), then I was not able to reproduce this behavior with both the standard buttons and our RadButtons.

Moreover, the workaround I provided Seth with was regarding an issue where the button was clicked without holding the Alt key. My workaround should suffice in the cases you are describing.

In order to provide you with further assistance I would like to ask you to elaborate the matters I pointed out above and describe the problems in more details.

Looking forward to your reply.

Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Jose
Top achievements
Rank 1
answered on 10 Jan 2014, 08:50 PM

George thank you for the response.  

I suppose best explanation was stated in the original post from Rajesh.  Where if theirs is a hotkey button and you key press a letter that pertains to a hotkey button while you are in the dropdown in the grid it will fire the hotkey.  If you key press a letter that does not have a hotkey button the dropdown will select the corresponding list item in the dropdown.  In my example if I press “B” or “U” the hot key button fires.  If I press “A” the first “A” list item shows up “ABrown1” in the dropdown.

 

Your second point on the work around… all that does is validate that Alt-Key was press prior to firing the Button.Click event.  Your workaround had to be extend to include a few more event captures to work properly  (If TypeOf e Is MouseEventArgs OrElse WasEnterKey OrElse Form.ModifierKeys = Keys.Alt Then) .  Not a biggie.

 

To elaborate on "It does not address the fact that the keypress is not picked up or used in the grid" … For each button Click event we are running (ValidButtonClick) to avoid unwanted HotKey firings.   But the dropdown does not seem to capture the key press event.  Using my original code example with (“A”, “B”, “U”) … if “A” is pressed in the combo box “ABrown1” will display….  If “B” or “U” is pressed the dropdown does not do anything….  Hence,  Keypress is not picked up by the grid.


If you add the below validButtonClick to my original code and test on the button click event you will see the the dropdown will not work for any keypress other than "A"

 

Public Function ValidButtonClick(ByVal e As System.EventArgs) As Boolean

    If TypeOf e Is MouseEventArgs OrElse WasEnterKey OrElse Form.ModifierKeys = Keys.Alt Then

            Return True

    Else

            Return False

    End If

End Function

 

Private Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click

                If not ValidButtonClick then Exit Sub
                MsgBox("Button1 Clicked")
End Sub

 
Thanks again.

 

0
George
Telerik team
answered on 14 Jan 2014, 02:39 PM
Hi Jose,

Thank you for your reply.

I was not able to reproduce this issue in a sample project, using both - your designer file or my own project. Below you can find my project, please check it out and let me know if there is something that I am missing. Also, if possible please provide me with a sample project where the issue is reproduced so I can properly investigate the issue further. Please, include the full code along with instructions.

Looking forward to your reply.

Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Jose
Top achievements
Rank 1
answered on 15 Jan 2014, 06:40 PM
George thanks for the project.   I did run it and with a telerik button it works fine.  The moment I added a windows button to the form it did not work correctly.  I also went back to Q2 version and it did the same thing.  So I guess I'm stuck with having to change the buttons on the forms if I want it to work correctly.   I do appreciate your time and effort.

Designer code:

    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.Button1 = New System.Windows.Forms.Button()
        Me.SuspendLayout()
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(104, 95)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(75, 23)
        Me.Button1.TabIndex = 0
        Me.Button1.Text = "&Add"
        Me.Button1.UseVisualStyleBackColor = True
        '
        'Form1
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(284, 262)
        Me.Controls.Add(Me.Button1)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub
    Friend WithEvents Button1 As System.Windows.Forms.Button

Code: 
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        MsgBox("I was clicked")
    End Sub

0
George
Telerik team
answered on 20 Jan 2014, 12:34 PM
Hello Jose,

Thank you for your reply.

It appears that this behavior is normal for WinForms as per this StackOverflow article. Although this behavior is corrected in our RadControls you will need to implement the mentioned in the article workaround for the standard .NET controls.

I hope this helps.

Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Rajesh
Top achievements
Rank 1
Answers by
Svett
Telerik team
Seth
Top achievements
Rank 1
George
Telerik team
Jose
Top achievements
Rank 1
Share this question
or