如何在vb.net中创建切换按钮 [英] how to create a toggle button in vb.net
本文介绍了如何在vb.net中创建切换按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,我需要制作一个用于隐藏标签对象或再次出现的按钮。
所以当按下按钮时我需要按钮像开关一样下沉并使标签消失当再次按下时,变成凸起并出现标签。
任何想法如何创建切换按钮?
hello, i need to make a button that is used to hid a label object or make appear again.
so i need the button when pressed to sink in like a switch and make the label disappear and when pressed again, become raised and make label appear.
any idea how to create a toggle button?
推荐答案
只需使用此代码
simply use this code
checkBox.Appearance = System.Windows.Forms.Appearance.Button
您可以使用复选框。
您也可以在单击事件处理程序中使用普通(推送)按钮只需切换标签的可见
属性:
You may use a checkbox for the purpose.
You may also use an ordinary (push) button, in the click event handler just toggle theVisible
property of the label:
myLabel.Visible = Not myLabel.Visible
切换按钮只不过是一个简单的按钮
请求一个值(例如,这个布尔值为true)
然后再作为实现if(boolean == true)这样做吗
A toggle-Button is nothing more than a simple Button which
asks for a value (for example is this boolean true)
and after that a simple if(boolean == true) do this else do that
boolean boo = false;
buttonPressed()
{
if(boo == true)
{
boo = false;
doSomething.Visible = true;
}
else
{
boo = true;
doSomething.Visible = false;
}
}
这篇关于如何在vb.net中创建切换按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文