Reputation: 83
Could somebody help me with my problem on my drop down menu?
I have 4 buttons inside the panel. The size of each button is 132
, 29
. My problem is when I hover the mouse on the button nothing happens.
int t1 = 29;
private void pnlFeature_MouseHover(object sender, EventArgs e)
{
timer1.Start();
}
private void pnlFeature_MouseLeave(object sender, EventArgs e)
{
timer1.Stop();
t1 = 29;
}
private void timer1_Tick(object sender, EventArgs e)
{
if (t1 > 116)
{ timer1.Stop(); }
else
{
this.pnlFeature.Size = new Size(this.pnlFeature.Size.Width, t1);
t1 += 4;
}
}
private void frmMain_MouseHover(object sender, EventArgs e)
{
this.pnlFeature.Size = new Size(this.pnlFeature.Size.Width, t1);
}
Upvotes: 0
Views: 157
Reputation: 1733
Because you move mouse on buttons not the panel object. Write a hover event handler for one of the buttons and assign it to all four buttons "MouseHover" event handlers and in your code you can find out mouse moved over which button :
private void button1_MouseHover(object sender, EventArgs e)
{
if (!(sender is Button))
return;
Button tmp = (Button) sender;
switch (tmp.Name)
{
case "Button1":
break;
case "Button2":
break;
case "Button3":
break;
}
}
Upvotes: 3