改变menustrip backcolor c# [英] Change menustrip backcolor c#

查看:215
本文介绍了改变menustrip backcolor c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究winForms C#2.0。

我想改变我的menustrip的背景颜色。它看起来像写 menustrip1.Backcolor = Color.FromArgb(38,37,37); 一样简单,但我遇到两个问题:



1)所有toolstripmenuitems仍然使用控件backcolor。 (我已经逐一设置了背景但是......)



2)每个toolstipSeparator都保留白色背景,如果我为每个分隔符设置了背景颜色,则没有碰巧,它仍然有控制颜色。



我试图将renderMode设置为System但这不能解决我的问题。

另外我尝试制作自己的渲染器但是我得到了相同的结果。



我看到contextMenuStrips可以很容易地进行背景颜色改变并且它会一致地改变(项目和分隔符)。 />


提前致谢。 CCB

I'm working on winForms C# 2.0.
I want to change the backcolor of my menustrip. It looks as simple as writing menustrip1.Backcolor = Color.FromArgb(38, 37, 37); but I'm having two problems:

1) all toolstripmenuitems are still with the control backcolor. (I already set their backcolor one by one but...)

2) Each toolstipSeparator stays with the white backcolor and if I set a backcolor to each separator, nothing happens, it still has the control color.

I tried to set the renderMode to System but that does not fix my problem.
Also I tried making my own renderer but I got the same result.

I saw that contextMenuStrips can be easily backcolor changed and it changes uniformly(items and separators) .

Thanks in advance. CCB

推荐答案

您始终可以使用属性 Items 遍历所有菜单条项并更改每个菜单项的背景颜色一:

https://msdn.microsoft.com/en-us/library/system.windows.forms.toolstrip.items%28v=vs.110%29.aspx [ ^ ],

https://msdn.microsoft.com/en-us/library/system.windows.forms.toolstripitemcollection%28v=vs.110%29.aspx [ ^ ](使用 foreach with the property),

这是项目类: https:// msdn.microsoft.com/en-us/library/system.windows.forms.toolstripitem%28v=vs.110%29.aspx [ ^ ],

它还有属性 BackColor https://msdn.microsoft.com/en-us/library/system.windows.forms.toolstripitem.backcolor%28v=vs.110%29.aspx [ ^ ]。



-SA
You can always traverse all menu strip items using the property Items and change the background color of each one:
https://msdn.microsoft.com/en-us/library/system.windows.forms.toolstrip.items%28v=vs.110%29.aspx[^],
https://msdn.microsoft.com/en-us/library/system.windows.forms.toolstripitemcollection%28v=vs.110%29.aspx[^] (use foreach with the property),
this is the item class: https://msdn.microsoft.com/en-us/library/system.windows.forms.toolstripitem%28v=vs.110%29.aspx[^],
it also has the property BackColor: https://msdn.microsoft.com/en-us/library/system.windows.forms.toolstripitem.backcolor%28v=vs.110%29.aspx[^].

—SA


这篇关于改变menustrip backcolor c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆