如何在C#中添加一个复选框到toolstrip? [英] how to add a checkbox to toolstrip in C#?

查看:904
本文介绍了如何在C#中添加一个复选框到toolstrip?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个工具条,我想给它添加一个复选框,但我不知道该怎么做。

请帮帮我。

I have a toolstrip and i want to add a checkbox to it,but Idont know how to do it.
please help me.

推荐答案

表单加载事件中的



in form load event:
CheckBox cb = new CheckBox();
cb.Text = "test";
cb.CheckStateChanged += (s, ex) => this.Text = cb.CheckState.ToString();
ToolStripControlHost host = new ToolStripControlHost(cb);
toolStrip1.Items.Insert(0,host);



内联代码更改为代码块:它保留格式 - OriginalGriff [/ edit]


[edit]Inline code changed to Code block: it preserves the formatting- OriginalGriff[/edit]


在这里:

在C#中向ToolStrip添加控件 [ ^ ]

ToolStrip带有C#工具提示的复选框 [< a href =http://www.codecreations.com/site/blog/42-cc-blog/90-toolstrip-checkboxes-with-tooltips-in-ctarget =_ blanktitle =New Window> ^ ]
Here you go:
Adding controls to ToolStrip in C#[^]
ToolStrip Checkboxes with ToolTips in C#[^]


为此目的,请勿使用 CheckBox

ToolStrip 上你应该使用 ToolStripButton 哪个相同的功能作为 CheckBox 。只需使用 已检查属性!
Don't use a CheckBox for this purpose.
On a ToolStrip you are supposed to use a ToolStripButton which has the same functionality as a CheckBox. Just use its Checked property!


这篇关于如何在C#中添加一个复选框到toolstrip?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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