设计界面:2个button,一个panel
当鼠标移动到btnHome时,显示menuPanel
当鼠标离开btnHome时,隐藏menuPanel
当btnPin箭头向左时,menuPanel为自动隐藏状态
当btnPin箭头向下时,menuPanel为固定显示状态
From1代码:
namespace Demo
{
public partial class Form1 : Form
{
public int pin = ; public Form1()
{
InitializeComponent();
menuPanel.Visible = false;
} void ChangeIconPin()
{
switch (pin)
{
case :
//Changes the pin-icon to display a unpinned frame.
this.btnPin.BackgroundImage = Demo.Properties.Resources.left;
break; case :
//Changes the pin-icon to display a pinned frame.
this.btnPin.BackgroundImage = Demo.Properties.Resources.down;
break;
}
} private void btnHome_MouseHover(object sender, EventArgs e)
{
menuPanel.Visible=true;
} private void Form1_MouseEnter(object sender, EventArgs e)
{
if (pin == )
{
menuPanel.Visible = false;
}
else
{
return;
}
} private void btnPin_Click(object sender, EventArgs e)
{
switch (pin)
{
case :
pin = ;
ChangeIconPin();
break;
case :
pin = ;
ChangeIconPin();
break;
}
}
}
}