Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Panelbar (obsolete as of Q2 2010) > Disable Right Click

Answered Disable Right Click

Feed from this thread
  • Surendar S avatar

    Posted on Dec 28, 2010 (permalink)

    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?

    Reply

  • Alexander Alexander admin's avatar

    Posted on Dec 29, 2010 (permalink)

    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.

    Reply

  • Surendar S avatar

    Posted on Dec 30, 2010 (permalink)

    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?

    Reply

  • Answer Alexander Alexander admin's avatar

    Posted on Jan 3, 2011 (permalink)

    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.

    Reply

  • Surendar S avatar

    Posted on Jan 5, 2011 (permalink)

    Now it works. Thanks a lot.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Panelbar (obsolete as of Q2 2010) > Disable Right Click
Related resources for "Disable Right Click"

[ Features | Demos | Documentation | Knowledge Base | Telerik TV | Code Library | Step-by-step Tutorial | Blogs | Self-Paced Trainer ]