I try to find an event for if you rightclick and leftclick a buttoncontrol in a Form application. Simply, to detect if it is the left or right button on the mouse that is clicked.

What I want to do is that if I rightclick a button I want the button to change backcolor to Red and when I Leftclick the button I want the button to change backColor to Blue.
The only event I can find is "MouseClick".
Is this possible to use in any way to further detect if it is left or rightclick ?

I donĀ“t get the below to work. What could be wrong here ?
CompileError:
could not deduce template argument for 'const std::vector<_Ty,_Alloc> &' from 'System::Windows::Forms::MouseButtons'

RightClickEvent:

private: System::Void button5_MouseDown(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) 
{
	 if( e->Button == Buttons::Right)
                {
                     button1->BackColor = Color::Red;
                 }
}

LeftClickEvent:

private: System::Void button5_MouseDown(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) 
{
	 if( e->Button == Buttons::Left)
                {
                     button1->BackColor = Color::Blue;
                 }
}

I have tried these 4 different lines of codes to detect if the mouse was rightclicked and none of them compiles.
How is the way to detect rightclick of the mouse.
For the event below I am using:
private: System::Void button5_MouseDown(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e)

e->Button == Button::Right
e->Button == Buttons::Right
e->Button::get() == Button::Right
e->Button::get() == Buttons::Right

try if (e->Button::get() == Buttons::Right)

I did find the answer and it is:

//Detect LeftClick etc...

e->Button == System::Windows::Forms::MouseButtons::Left
This question has already been answered. Start a new discussion instead.