C# ContextMenuStrip 项属性!
如何根据值设置和获取上下文菜单条中项目的文本和/或背景的颜色值?
这段代码正确吗?
ContextMenuStrip1.Items.Add("this is an item").BackColor = Color.FromArgb(255, 179, 179);
但我找不到获取颜色值的方法!
我这样做了:
int i = ContextMenuStrip1.Items.IndexOfKey("this is an item");
Color c = ContextMenuStrip1.Items[i].BackColor; // I get error in here!
但它不起作用!!!!
还如何根据项目字符串值获取或/和设置其他属性(例如“这是一个项目”)?
干杯
how to set and get the colors value to text and/or Background of an item in a context menu strip based on the value?
is this code right way?
ContextMenuStrip1.Items.Add("this is an item").BackColor = Color.FromArgb(255, 179, 179);
but I can not find out a way to get the color value!
I did this:
int i = ContextMenuStrip1.Items.IndexOfKey("this is an item");
Color c = ContextMenuStrip1.Items[i].BackColor; // I get error in here!
but it is not working !!!!
also how to get or/and set other properties based on the item string value (example "this is an item")?
cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“键”是 ToolStripItem.Name 属性。请尝试以下操作:
the "key" is the ToolStripItem.Name property. Try the following: