Disable Right Click

5 posts, 1 answers
  1. Surendar S
    Surendar S avatar
    33 posts
    Member since:
    Nov 2009

    Posted 28 Dec 2010 Link to this post

    Hi,
        I want to diable the right click option in the RadpanelbarGroupElement. How should i acheive it?
    As of now am giving the message box in the mouse down event. Below is the code that i have used.
    Private Sub RadPanelBar1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles RadPanelBar1.MouseDown
           Try
               If e.Button = Windows.Forms.MouseButtons.Right Then
                   RadMessageBox.Show("Right click not allowed.")
                   Exit Sub
               End If
           Catch ex As Exception
               RadMessageBox.Show(ex.ToString)
           End Try
       End Sub
    I dont need to intimate the user about this. How this should be done?
  2. Alexander
    Admin
    Alexander avatar
    306 posts

    Posted 29 Dec 2010 Link to this post

    Hello Surendar,

    Thank you for your question.

    There is no build-in mechanism which allows disabling the right mouse button in the RadPanelBar control. You can set a boolean variable instead of showing a MessageBox and use it in your project. Please give us more details regarding your scenario. This will help me to find the best approach for your case.

    I am looking forward to your response.

    Best regards,
    Alexander
    the Telerik team
    Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Surendar S
    Surendar S avatar
    33 posts
    Member since:
    Nov 2009

    Posted 30 Dec 2010 Link to this post

    Hi Alexander,
        I have tried it out and it is not working for me.
    Private Sub RadPanelBar1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles RadPanelBar1.MouseDown
           Try
               If e.Button = Windows.Forms.MouseButtons.Right Then
                   Dim booleanvalue As Boolean = False
                   ' RadMessageBox.Show("Right click not allowed.")
                   'Exit Sub
               End If
           Catch ex As Exception
               RadMessageBox.Show(ex.ToString)
           End Try
       End Sub

    I have also RadPanelBarGroupElement click event and i hope this is firing the event. Is there any solution for this?
  5. Answer
    Alexander
    Admin
    Alexander avatar
    306 posts

    Posted 03 Jan 2011 Link to this post

    Hello Surendar,

    The approach I described is using a global variable in your class which indicates if the right mouse button has been clicked. You can use it to skip some logic in your application which should be executed when the right button is clicked as in this code snippet:

    Private RightButtonClicked As Boolean = False
    Private Sub RadPanelBar1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles RadPanelBar1.MouseDown
        Try
            If e.Button = Windows.Forms.MouseButtons.Right Then
                Me.RightButtonClicked = True
                Exit Sub
            End If
        Catch ex As Exception
            RadMessageBox.Show(ex.ToString)
        End Try
    End Sub
     
    Private Sub SomeMethod()
        ' if should skip right mouse button
        If Me.RightButtonClicked Then
            Me.RightButtonClicked = False
            Return
        End If
        ' method logic here
    End Sub

    Please provide me with more details concerning your scenario. It will help me to provide a more specific approach.

    Best regards,
    Alexander
    the Telerik team
    Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
  6. Surendar S
    Surendar S avatar
    33 posts
    Member since:
    Nov 2009

    Posted 05 Jan 2011 Link to this post

    Now it works. Thanks a lot.
Back to Top
UI for WinForms is Visual Studio 2017 Ready