TabRenderer 没有启用视觉样式?
我想绘制一个具有自定义功能的自定义 TabControl
。
为此,我继承了 Panel 类并重写了 OnPaint 方法以使用 TabRenderer
类进行绘制。
问题是 TabRenderer
仅在启用视觉样式时工作(可以使用 TabRenderer.IsSupported
检查),但是如果禁用视觉样式我该怎么办?
在这种情况下,我想到使用 ControlPaint
类来绘制没有视觉样式的选项卡,但它没有与选项卡相关的绘制方法。我希望它在视觉上基本上像常规的 TabControl 一样。
I want to draw a custom TabControl
with custom functionality.
To do this, i inherited the Panel class and overrided OnPaint method to draw with TabRenderer
class.
The problem is that TabRenderer
working only when visual styles enabled (can be checked with TabRenderer.IsSupported
), but what should i do if visual styles disabled?
In this case, I thought using the ControlPaint
class to draw tabs without visual styles, but it has no draw methods related to Tabs. I want it basically to behave visually like the regular TabControl
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你必须自己绘制它,因为没有公开的API。希望以非视觉风格的方式相对容易做到这一点。
您可以使用 ControlPaint.DrawBorder3D 并对按钮使用类似以下代码:
You have to draw it by yourself, because there is not published API for this. Hopefully this is relatively easy to do it in non-visualstyles way.
You can draw pane border with ControlPaint.DrawBorder3D and use something like the following code for buttons:
这是一个“外面”的答案,但是您可以使用 wpf 吗?正如您从上面的答案中看到的那样,在 winform 中自定义控件是一件很痛苦的事情,而在 WPF 中,每个控件都是不好看的。这意味着您可以完全控制渲染的内容及其外观。
This is an "out there" answer but is it possible that you could use wpf? As you can see from the answer above it is a pain in the ear to customise controls in winforms where as in WPF each control is lookless. This means that you control what is rendered and how it looks completely.