【发布时间】:2014-02-28 14:35:34
【问题描述】:
我有一个 DataGridView,它的右侧有一个用户控件滚动条。在 DataGridView 内滑动时,我在 DataGridView 中得到滚动事件,它工作正常(来自滑动)。不幸的是,如果我在滑过 DataGridControl(DataGridView 之外)后立即滑过自定义滚动条,DataGridView 仍然会从滑动中获取滚动事件。当滑动(即思考鼠标位置)发生在 DataGridView 控件之外时,我想阻止 DataGridView 中的这些滚动事件。相反,应该单击并滚动 DataGridView 外部的滚动条。我可以单独管理自定义滚动条的滚动。想法赞赏。我看不到取消滚动事件的简单方法(在事件本身内)。感谢您的关注,任何帮助都非常感谢。我在stackoverflow中没有看到答案。
对于德米特里的回答(由于太久无法发表评论):我试过了,但得到一个参数超出范围异常“索引超出范围。必须是非负数且小于大小集合的名称。\r\n参数名称:索引"。在 System.Collections.ArrayList.get_Item(Int32 索引) 在 System.Windows.Forms.DataGridViewRowCollection.SharedRow(Int32 rowIndex) 在 System.Windows.Forms.DataGridView.ScrollRowsByHeight(Int32 高度) 在 System.Windows.Forms.DataGridView.set_VerticalOffset(Int32 值) 在 System.Windows.Forms.DataGridView.DataGridViewVScrolled(对象发送者,ScrollEventArgs se) 在 System.Windows.Forms.ScrollBar.OnScroll(ScrollEventArgs se) 在 System.Windows.Forms.ScrollBar.DoScroll(ScrollEventType 类型) 在 System.Windows.Forms.ScrollBar.WmReflectScroll(消息和 m) 在 System.Windows.Forms.ScrollBar.WndProc(消息和 m) 在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(消息& m) 在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(消息和 m) 在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,Int32 msg,IntPtr wparam,IntPtr lparam)。想法和感谢?
【问题讨论】:
标签: c# winforms events scroll touch