状态按钮 [英] State Button
问题描述
嗨。
可以做一个状态按钮吗? (州选择,并且状态不是
选择)
我想做一个选择:例如男/女是/否。
所以,如果用户选择是,则不会选择否,并且选择是>
。
有一个简单的方法吗?我错过了Button属性中的某些内容吗?
谢谢
Hi.
Is it possible to do a State Button ? (state selected, and state not
selected)
I want to do a choice : for example male/female yes/no.
So, if the user select Yes, no will be not selected, and Yes will be
selected.
Is there a simple way ? Have I miss something in the Button property ?
Thanks
推荐答案
您好Mathieu,
好吧,您可以使用文本框,并将外观设置为按钮,或使用单击a按钮时切换的
布尔标志。
在任何一种情况下,你都需要自己更改按钮的文字。
private bool yes = true;
private void button1_Click(object sender,System.EventArgs e)
{
yes =!yes;
if(yes)
button1.Text ="是" ;;
else
button1.Text =" No";
}
private void checkBox1_CheckedChanged(object sender,System.EventArgs e)
{
if(checkBox1.Checked)
checkBox1.Text ="是" ;;
else
checkBox1.Text =" No";
}
快乐的编码!
Morten Wennevik [C#MVP]
Hi Mathieu,
Well, you can use a textbox, and set the Appearance to Button, or use a
boolean flag that you switch when the a button is clicked.
In either case, you will need to change the text of the button yourself.
private bool yes = true;
private void button1_Click(object sender, System.EventArgs e)
{
yes = !yes;
if(yes)
button1.Text = "Yes";
else
button1.Text = "No";
}
private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
{
if(checkBox1.Checked)
checkBox1.Text = "Yes";
else
checkBox1.Text = "No";
}
Happy coding!
Morten Wennevik [C# MVP]
为什么不使用面板/组合框内的单选按钮,你甚至可以设置单选按钮的
外观显示为按钮甚至可以
包括图片
-Benny
Mathieu Chavoutier写道:
Why not use a radio button inside a panel/groupbox, you can even set the
appearance of the radio button to appear as a button and can even
include images
-Benny
Mathieu Chavoutier wrote:
嗨。
可以做一个状态按钮吗? (状态选择,状态未选择)
我想做一个选择:例如男/女是/否。
因此,如果用户选择是,则不会选择否,将会被选中。
有一个简单的方法吗?我有没有错过Button属性的内容?
谢谢
Hi.
Is it possible to do a State Button ? (state selected, and state not
selected)
I want to do a choice : for example male/female yes/no.
So, if the user select Yes, no will be not selected, and Yes will be
selected.
Is there a simple way ? Have I miss something in the Button property ?
Thanks
" Morten Wennevik" <莫************ @ hotmail.com> écritdansle message de
news:opr7voc9sihntkfz @ localhost ...嗨Mathieu,
嗯,您可以使用文本框,并将外观设置为按钮,或使用
单击a按钮时切换的布尔标志。
在任何一种情况下,您都需要自己更改按钮的文本。
"Morten Wennevik" <Mo************@hotmail.com> a écrit dans le message de news:opr7voc9sihntkfz@localhost... Hi Mathieu,
Well, you can use a textbox, and set the Appearance to Button, or use a
boolean flag that you switch when the a button is clicked.
In either case, you will need to change the text of the button yourself.
我不是只做一个按钮,而是改变它的状态。
这是一个好主意,但是,我的程序将被那些甚至不能使用的人使用
必须
知道什么是电脑。所以,如果他们看不到他们的眼睛下面有很多
的解决方案,那对他们来说就难了。我的目标如果要做一个非常简单的
程序来使用。
但是,谢谢你,我会尝试将这个想法留给另一个程序:o) 。
I didn''t though to do only one button, and to change its state.
It is a good idea, but, my program will be used by people who don''t even
have to
know what is a computer. So, if they can''t see that there are a lots of
solution under their
eyes, it will be to hard for them. My objectiv if to do a really simple
program to use.
But, thank you, I will try to keep this idea for another program :o).
这篇关于状态按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!