不可点击的上下文菜单标题 [英] Non-clickable Context Menu Header

查看:110
本文介绍了不可点击的上下文菜单标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在创建上下文菜单,有没有包括标题文本的方法吗?例如,当用户点击一个按钮,我想一个上下文菜单有两个选项显示。还应该有文本上方的选项,用句,如:请选择一个选项



这是可能的。


<? DIV CLASS =h2_lin>解决方案

您不能与设计师做的,但你可以在代码中做到这一点:

 公共部分Form1类:表格{
公共Form1的(){
的InitializeComponent();
contextMenuStrip1.Items.Insert(0,新ToolStripLabel(请选择一个选项));
contextMenuStrip1.Items.Insert(1,新ToolStripSeparator());
}
}


When creating a context menu, is there a way to have header text included? For example, when a user clicks a button, I want a context menu to show with two options. There should also be text above the options, with a sentence such as: 'Please select an option'.

Is this possible?

解决方案

You can't do it with the designer but you can do it in code:

public partial class Form1 : Form {
    public Form1() {
        InitializeComponent();
        contextMenuStrip1.Items.Insert(0, new ToolStripLabel("Please select an option"));
        contextMenuStrip1.Items.Insert(1, new ToolStripSeparator());
    }
}

这篇关于不可点击的上下文菜单标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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