C#:覆盖 DataGridView 滚动条(自定义 OnPaint)?
我有一个继承自 DataGridView 的用户控件。我已经重写了 OnRowPrePaint、OnRowPostPaint、OnCellPaint 和其他一些内容,这样我就可以根据需要绘制整个内容。除了滚动条之外,一切都运行得很漂亮。如何拦截正在绘制的滚动条并绘制自己的滚动条?
理想情况下,有一些数据结构包含滚动条本身的边界以及实际滚动滑块的边界。然后我就可以在这些位置的图形层上绘图。
有办法做到这一点吗?似乎其他一切都已考虑在内,所以我想有某种方法可以做到这一点......
I have a usercontrol that inherits from a DataGridView. I have overridden OnRowPrePaint, OnRowPostPaint, OnCellPaint, and some others so I can draw the entire thing as I want. Everything works beautifully, except the scrollbars. How can I intercept the scrollbars being painted and paint my own?
Ideally there is some datastructure that contains the bounds for the scroll bar itself as well as the bounds for actually scroll-slider. Then I can just draw on the graphics layer at those locations.
Is there a way to do this? It seems like everything else was though of, so I would imagine there is some way to do it...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从滚动条类继承时,将其添加到 Sub New:
OnPaint 事件现在将触发。
要覆盖单击控件时绘制的标准按钮/滑块:
并减少闪烁:
编辑:
我显然需要学习阅读。
没有注意到
位......
When inheriting from the scrollbar class, add this to Sub New:
The OnPaint event will now fire.
To override the standard buttons / slider from being drawn when clicking the control:
And to reduce the flicker:
EDIT:
I clearly need to learn to read.
Didn't notice the
bit........
首先想到的是:使用滚动条中的绘制事件。无论如何,滚动条都是从
Control
派生的。可能不是最佳解决方案...First thing that comes to mind: use the paint events from the scrollbars. The scrollbars are derived from
Control
anyway. Might not be the optimum solution...