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

Disable Right Click

4 Answers 43 Views
Panelbar (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Surendar S
Top achievements
Rank 1
Surendar S asked on 29 Dec 2010, 05:37 AM
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?

4 Answers, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 29 Dec 2010, 06:24 PM
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.
0
Surendar S
Top achievements
Rank 1
answered on 30 Dec 2010, 07:55 AM
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?
0
Accepted
Alexander
Telerik team
answered on 03 Jan 2011, 05:05 PM
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.
0
Surendar S
Top achievements
Rank 1
answered on 05 Jan 2011, 01:35 PM
Now it works. Thanks a lot.
Tags
Panelbar (obsolete as of Q2 2010)
Asked by
Surendar S
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Surendar S
Top achievements
Rank 1
Share this question
or