如何在C#Winform中检查鼠标移出TabPage?

时间:2015-12-15 08:20:41

标签: c# winforms

我想检查TabPage标签区域的鼠标离开。但它不能正常工作。有时候我有时候没有得到消息框。

  TabPage mouseTab = null;

 void tabControl1_MouseMove(object sender, MouseEventArgs e) {
      TabPage checkTab = null;

      for (int i = 0; i < tabControl1.TabPages.Count; ++i) {
        if (tabControl1.GetTabRect(i).Contains(e.Location)) {
          checkTab = tabControl1.TabPages[i];
        }
      }

      if (checkTab == null && mouseTab != null) {
        mouseTab = null;
MessageBox.Show("MouseLeave");
      } else if (checkTab != null) {
        if (mouseTab == null || !checkTab.Equals(mouseTab)) {
          mouseTab = checkTab;
        }
      }
    }

0 个答案:

没有答案