i have two panel in ma form. panel1 with button1 on it at location let say x:10,y:10 and panel2 with button 2 on it at location x:10,y:10.
what actually button1 do:- it hide panel1 and shows panel2 at the same location.
but whenever i click on button1 twice after completion its process it fire button2 click event,
plz help me ASAP
hope below link will demonstrate my prob clearly
http://www.youtube.com/watch?v=bpojl4XMweo&feature=g-upl
EDIT:
Code used so far
void hidepanel()
{
panel1.Visible = false;
panel2.Visible = false;
}
private void Form1_Load(object sender, EventArgs e)
{
hidepanel();
panel1.Visible = true;
panel2.Location = new Point(262,19);
panel1.Location = new Point(0, 0);
}
private void button1_Click(object sender, EventArgs e)
{
hidepanel();
panel2.Location = new Point(0, 0);
panel2.Visible = true;
}
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show("2");
}
just add some logic to hide/unhide enable/disable the oposite components. Just like this:
works for me like a charme:
regards
Josef
EDIT:
Now, I see the problem, the mouse clicks are enqueued into windows message queue and will fire the click event on button2 although you clicked on a disabled/hidden button1.
I found the solution here: Ignoring queued mouse events
and changed the code to:
where PeekMessage etc is defined another class:
Please test.
~josef