Condition to check mousr rigt click
if (text == "Done" || string.IsNullOrWhiteSpace(text) && ?)
showProgessBar = false;
else
showProgessBar = true;
In the above code
I need to add a condition that if we right click on any button in a page, progress bar should be visible else it should not be visible(i.e if we hove the mouse over the button, staus text will be displayed but progress bar should not be visible.
How to implement this?

Nitesh KejriwalRank #253 · 9.9K reputationPosted Sep 5, 2014, 5:03 AM EDT
divyashreenivasangm20 reputationPosted Sep 8, 2014, 2:16 AM EDT
VulpesRank #55 · 29.2K reputationPosted Sep 8, 2014, 3:01 AM EDT
This could be done as follows:
private void Form1_Load(object sender, EventArgs e)
{
HandleButtonMouseDownEvents(this);
}
private void HandleButtonMouseDownEvents(Control cc)
{
foreach (Control c in cc.Controls)
{
if (c is Button)
{
Button b = (Button)c;
b.MouseDown += button_MouseDown;
}
else if (c.HasChildren)
{
HandleButtonMouseDownEvents(c);
}
}
}
// add this eventhandler manually
private void button_MouseDown(object sender, MouseEventArgs e)
{
if ((text == "Done" || string.IsNullOrWhiteSpace(text)) && e.Button == MouseButtons.Right)
{
progressBar1.Visible = true;
}
else
{
progressBar1.Visible = false;
}
}