可以加一个timer控件,判断鼠标是否在图标上,我把我以前写过的类似功能的代码贴在下面供你参考~
private void timer1_Tick(object sender, EventArgs e)
{
//检查光标位置是否在面板内
Point p1 = this.panel1.PointToScreen(new Point(0, 0));
Point p2 = this.panel1.PointToScreen(new Point(listView1.Right, listView1.Bottom));
Point pCur = Cursor.Position;//当前鼠标光标位置
if (pCur.X < p1.X || pCur.X > p2.X || pCur.Y < p1.Y || pCur.Y > p2.Y)
{
this.listView1.Width = m_nPanFunHideWidth;
this.panel1.Width = m_nPanFunHideWidth;
}
else
{
this.listView1.Width = m_nPanFunWidth;
this.panel1.Width = m_nPanFunWidth;
}
}
MouseL什么的一个事件。找找看,记不太清楚了