如何以编程方式创建弹出菜单 [英] How to create pop up menu programatically

查看:95
本文介绍了如何以编程方式创建弹出菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我是C#语言的新手,我最近开始学习。我想通过编程创建弹出菜单。我正在使用Windows申请表。我可以使用工具箱中的contextmenustrip创建弹出菜单,但是如何在不使用工具箱绘图的情况下创建。我想通过编程来创建它。任何人都可以提供一些示例代码或示例。



提前致谢。

Hi,

I am new to C# language,I have started to learn recently. I want to create pop-up menu by programming. I am using windows application form. I am able to create pop up menu by using "contextmenustrip" from tool box, but how to create without drawing from toolbox. I want to create it by programming. Can any one provide me some sample code or examples.

Thanks in advance.

推荐答案

ContextMenuStrip cmp = new ContextMenuStrip();

cmp.Items.Add(From);

cmp.Items.Add(To);

cmp.Items.Add(重置);

this.ContextMenuStrip = cmp;



我用上面的方法实现了这一点代码。
ContextMenuStrip cmp = new ContextMenuStrip();
cmp.Items.Add("From");
cmp.Items.Add("To");
cmp.Items.Add("Reset");
this.ContextMenuStrip = cmp;

I have achieved this by using above code.


使用MessageBox类''静态方法。显示()

我已经证明了下面的过载。

Use the MessageBox class'' static method .Show()
I''ve demonstrated on of the over load below.
MessageBox.Show("Message","BoxTitle", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);


这篇关于如何以编程方式创建弹出菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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