我想检查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;
}
}
}