2

Okay, I know this is a stupid question, but I can't find it in the controls. Is there a Right-Click and a scrollbutton click control for a normal button?

Jon
  • 2,566
  • 6
  • 32
  • 52

3 Answers3

5

For mouse right click check this:

 private void button1_MouseDown(object sender, MouseEventArgs e) {
      if (e.Button == MouseButtons.Right) {
        // Do something
        //...
      }
    }

For scroll button click check this: Mouse Wheel Event (C#)

Community
  • 1
  • 1
DevT
  • 4,843
  • 16
  • 59
  • 92
1

There is no right click event in C#. But if you want to show some custom items when right click is done, this is possible in jQuery.

To disable the right click menu with jQuery for the page as a whole do this:

$(document).bind("contextmenu", function(e) {
    return false;
});

To do it for just a particular element do this:

$("#myid").bind("contextmenu", function(e) {
    return false;
});

To show a custom menu, you have to define a class and then change the bind function as follows.

#menu {
    display: none;
    position: absolute;
    padding: 10px;
    background-color: #ddd;
    border: 1px solid #000;
}

$(document).bind("contextmenu", function(e) {

    $('#menu').css({
        top: e.pageY+'px',
        left: e.pageX+'px'
    }).show();

    return false;

});

Following line is required for closing the menu when the page is clicked or the menu clicked:

$(document).ready(function() {

    $('#menu').click(function() {
        $('#menu').hide();
    });
    $(document).click(function() {
        $('#menu').hide();
    });

});
Narendra
  • 3,069
  • 7
  • 30
  • 51
0

You can perhaps use this post for rightclick and for scollbuttonclick I guessed that you used WPF? Your question didn't mention anything about what you are using.

Community
  • 1
  • 1
Jonas W
  • 3,200
  • 1
  • 31
  • 44