'MouseUp rightclick works where MouseClick doesn't
I'm making a GUI in C#, and am trying to handle right clicks. I started with adding a Click event to each button, which didn't work, and I found this question, which led me to use MouseClick.
private void InitializeComponent() {
...
var b = new Button();
b.Dock = DockStyle.Fill;
...
b.MouseClick += OnClick;
b.text = "";
...
}
private void OnClick(object sender, MouseEventArgs e) {
if (e.Button == MouseButtons.Right)
((Button)sender).Text = "right ";
((Button)sender).Text += "clicked";
}
Now, when I left click it works, but right click is still not recognized. However, b.MouseUp += OnClick works correctly.
Does anyone know why that is?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
