我正在尝试了解MouseWheel事件之前正在执行的操作。
我所做的:
mousewheel += new MouseEvenHandler(mymethod)
。然后使用bool变量跟踪控件(ZEDGRAPH)何时具有焦点和何时没有焦点。 verticalscroll.value = (int)mydesiredposition;
这可以完成我想要的操作,即忽略窗体中的mousewheel事件并专注于控件。 我正在苦苦挣扎的事实是,当我滚动表单时,每次都会闪烁并向下滚动,直到到达设置的滚动条值。
所以我想知道的是,在导致该鼠标事件处理程序闪烁的mouseeventhandler之前触发了什么操作?
我的代码快照:
public Form(Form1 f)
{
InitializeComponent();
this.MouseWheel += new MouseEventHandler(mousewheel);
}//end of constructor
//
//
bool mousehoverZedGraph1 = false;
bool mousehoverZedGraph2 = false;
//
//
private void zedGraphControl1_MouseHover(object sender, EventArgs e)
{
mousehoverZedGraph1 = true;
return;
}
private void mousewheel(object sender, MouseEventArgs e)
{
if (mousehoverZedGraph1 == true)
{
VerticalScroll.Enabled = false;
VerticalScroll.Value = 0;
return;
}
else if (mousehoverZedGraph2 == true)
{
VerticalScroll.Value = 429;
VerticalScroll.Enabled = false;
}
else
{
//VerticalScroll.Value += e.Delta;
}
}
private void Form_MouseEnter(object sender, EventArgs e)
{
mousehoverZedGraph1 = mousehoverZedGraph2 = false;
VerticalScroll.Enabled = true;
}
小的 video 突出了闪烁: