HMJING
**过程虽可贵,结果价更高**

 在ListBox中,是没有选中项的双击事件的,所以为了实现双击事件绑定的就是ListBox的MouseDoubleClick事件,如和做到点击空项时不执行操作,其实是可以做判断的

private void lbCommand_MouseDoubleClick(object sender, MouseEventArgs e)
{
int index = this.lbCommand.IndexFromPoint(e.Location);
if (index != System.Windows.Forms.ListBox.NoMatches)
{

     Messbox.show(this.lbCommand.SelectItem.tostring()); //执行双击事件

}
else
{
      lbCommand.SelectedIndex = -1;//不做任何操作,将ListBox的选中项取消
}
}

posted on 2016-02-02 15:55  HMJING  阅读(4900)  评论(1)    收藏  举报