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?
VulpesPosted Sep 8, 2014, 7:01 AM
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;
}
}
divyashreenivasangmPosted Sep 8, 2014, 6:16 AM
Nitesh KejriwalPosted Sep 5, 2014, 9:03 AM