VB 中的选择性递归组件重新着色
我以前问过一个非常类似的问题,但这次不是关于 VB 语法,而是关于最好的方法。我正在制作一种方法,当传递一个组件时,它将重新着色它以及其中包含的所有组件。下面是我到目前为止的代码,但它并没有对所有组件重新着色,而只是对少数组件进行重新着色。我的主要问题是按钮保持“3D”样式而不是变得“扁平”。
If TypeOf comp Is System.Windows.Forms.ButtonBase Then
Dim c As System.Windows.Forms.ButtonBase
c = comp
c.FlatStyle = Windows.Forms.FlatStyle.Flat
c.BackColor = getColor(style, PART_BOX)
c.ForeColor = getColor(style, PART_TEXT)
comp = c
End If
传递的组件是 comp
,getColor
方法查找数据库并返回与传递给该方法的 part
参数相对应的颜色。这适用于所有低级组件和所有简单组件(例如标签)。
>你可以看到,这不是我想要的结果。 有人知道如何重新着色微调器、按钮和菜单栏吗?同样,我需要将按钮最终变成扁平的。
I've asked a very similar question before, but this time is not about VB syntax, but rather the best approach. I'm making a method that, when passed a component, will recolor it and all components contained within it. Below is the code I have so far, but it is not recoloring all components, instead only a mere few. My main problem is buttons staying in their "3D" styles and not becoming "flat".
If TypeOf comp Is System.Windows.Forms.ButtonBase Then
Dim c As System.Windows.Forms.ButtonBase
c = comp
c.FlatStyle = Windows.Forms.FlatStyle.Flat
c.BackColor = getColor(style, PART_BOX)
c.ForeColor = getColor(style, PART_TEXT)
comp = c
End If
The component passed is comp
, and the getColor
method looks into a database and returns a color corresponding to the part
parameter passed to the method. This works for all low-level components and all simple components like labels.
As you can see, this is not my preferred outcome. Does anyone know how to recolor spinners, buttons, and menu bars? Again, I need the button to end up being flat.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以绘制自己的菜单栏。请参阅:http://msdn.microsoft.com/ en-us/library/tdk48z0c(v=VS.100).aspx
按钮具有 BackColor 属性和 FlatStyle 属性:
http://msdn.microsoft.com/en-us/library/system.windows.forms.buttonbase.flatstyle.aspx
You can draw your own menu bars. See: http://msdn.microsoft.com/en-us/library/tdk48z0c(v=VS.100).aspx
Buttons have a BackColor property and a FlatStyle property:
http://msdn.microsoft.com/en-us/library/system.windows.forms.buttonbase.flatstyle.aspx