在我的应用程序中,当右键单击对象时,我使用弹出菜单项。我使用如下代码动态构建此菜单:
ContextMenuStrip menu = new ContextMenuStrip();
menu.Items.Add(new ToolStripMenuItem("Item1", aNiceImage, someFunction));
menu.Items.Add(new ToolStripMenuItem("Item2", alsoNiceImage, someOtherFunction));
现在,我想将其中一个菜单项设置为粗体(正如Windows用户体验指南所建议的那样),以指示哪个操作与双击对象相对应。
我该怎么做呢?
发布于 2011-10-24 21:10:11
使用item.Font = new Font(item.Font, item.Font.Style | FontStyle.Bold)
使当前字体具有粗体效果。
您还可以自动选择默认项目,如下所示:
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
{
contextMenuStrip1.Items[3].Select();
}
https://stackoverflow.com/questions/7876061
复制相似问题