gpt4 book ai didi

c# - Windows.Forms DragLeave 事件意外触发

转载 作者:行者123 更新时间:2023-11-30 21:03:44 29 4
gpt4 key购买 nike

自定义 UserControl ChartControlShelf 包含一个 TableLayoutPanel 和 3 个子控件,所有类型都是 Panel。 children 没有 EventHandlers。

ShelfContainer 为 UserControl ChartControlShelf 添加所有事件处理程序:

ChartControlShelf chartControlShelf = new ChartControlShelf();
chartControlShelf.DragOver+=new DragEventHandler(chartControlShelf_DragOver);
chartControlShelf.DragLeave+=new EventHandler(chartControlShelf_DragLeave);

....

private void chartControlShelf_DragOver(object sender, DragEventArgs e) {

ChartControlShelf chartControlShelf = (ChartControlShelf)sender;

if (chartControlShelf.panelControlShelf.PointToClient(Cursor.Position).Y < chartControlShelf.tlpChartControlShelf.Size.Height / 2) {
chartControlShelf.panelInsertTop.BackColor = CustomColorsColors.DragEnter;
chartControlShelf.panelInsertBottom.BackColor = CustomColorsColors.DragLeave;
}
else {
chartControlShelf.panelInsertBottom.BackColor = CustomColorsColors.DragEnter;
chartControlShelf.panelInsertTop.BackColor = CustomColorsColors.DragLeave;
}
}

private void chartControlShelf_DragLeave(object sender, EventArgs e) {
ChartControlShelf chartControlShelf = (ChartControlShelf)sender;
chartControlShelf.panelInsertTop.BackColor = CustomColorsColors.DragLeave;
chartControlShelf.panelInsertBottom.BackColor = CustomColorsColors.DragLeave;

}

为什么 *chartControlShelf_DragLeave* 在我的鼠标离开 ChartControlShelf UserControl 之前触发?

最佳答案

鼠标光标“属于”指针下方直接可见的控件。听起来很奇怪,当光标“进入”ChartControlShelf 内的其中一个控件时,它也会“离开”ChartControlSelf。

关于c# - Windows.Forms DragLeave 事件意外触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12715910/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com