如何使用“clear”取消选中radiobutton?按钮? [英] How do I uncheck a radiobutton using a "clear" button?

查看:537
本文介绍了如何使用“clear”取消选中radiobutton?按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我目前正在构建计算器的过程,该计算器用于计算任何变量的值,前提是所有其他变量都分配了输入值。



到目前为止,它已经工作了,我添加了一个清除按钮,以便在用户希望以不同的方式开始新的计算时,可以删除所有文本框值值。



但是,我一直在使用radioButton来选择所需的输出,当我按下清除按钮时,为前一次计算选择的radioButton仍保留在原来的位置。 。



我希望能够设置它,以便在单击清除按钮时取消选中上一次选择的radioButton。



有谁可以帮我这个?任何建议将不胜感激。



谢谢。



以下是我当前代码的示例:



我尝试过:



Hi,

I'm currently the process of building a calculator designed to calculate the value of any variable provided all other variables are assigned an input value.

So far it's working and I have added a "Clear" button so that all the text box values can be erased should the user wish to start a new calculation with different values.

However, I have been using radioButton's to select the desired output, and when I press the "Clear" button, the radioButton selected for the previous calculation remains where it is.

What I'd like to be able to do it set it so that when the "Clear" button is clicked it will uncheck which ever radioButton was last selected.

Can anyone help me with this? Any advice would be greatly appreciated.

Thank you.

Below is a sample of my current code:

What I have tried:

public partial class Form1 : Form
    {
        double P1, P2, V1, V2, U1, U2, v1, v2, h1, h2, Q, W, Z, g, PChange, VChange, UChange, vChange, hChange;
        
        public Form1()
        {
            InitializeComponent();

            Z = 0;
            P1 = P2 = V1 = V2 = U1 = U2 = v1 = v2 = h1 = h2 = Q = W = Z;
            g = 9.81;
        }

        private void txtBox_P1In_TextChanged(object sender, EventArgs e)
        {
            double.TryParse(txtBox_P1In.Text, out P1);
        }


        private void btnClear_Click(object sender, EventArgs e)
        {
            txtBox_P1In.Clear();
            txtBox_P2In.Clear();
            txtBox_Vol1In.Clear();
            txtBox_Vol2In.Clear();
            txtBox_U1In.Clear();
            txtBox_U2In.Clear();
            txtBox_vel1In.Clear();
            txtBox_vel2In.Clear();
            txtBox_h1In.Clear();
            txtBox_h2In.Clear();
            txtBox_QIn.Clear();
            txtBox_WIn.Clear();
            txtBox_P1Out.Clear();
            txtBox_P2Out.Clear();
            txtBox_V1Out.Clear();
            txtBox_V2Out.Clear();
            txtBox_U1Out.Clear();
            txtBox_U2Out.Clear();
            txtBox_vel1Out.Clear();
            txtBox_vel2Out.Clear();
            txtBox_h1Out.Clear();
            txtBox_h2Out.Clear();
            txtBox_QOut.Clear();
            txtBox_WOut.Clear();
            txtBox_P.Clear();
            txtBox_V.Clear();
            txtBox_U.Clear();
            txtBox_vel.Clear();
            txtBox_h.Clear();
            txtBox_P1In.Focus();
        }

        private void CalcButton_Click(object sender, EventArgs e)
        {
            if (radioButtonP1.Checked == true)
            {
                P1 = (((P2 * V2) + U2 + ((v2 * v2) / 2) + (g * h2) + W - Q - (g * h1) - ((v1 * v1) / 2) - U1) / V1);
                txtBox_P1Out.Text = P1.ToString();
                txtBox_P1In.Text = txtBox_P1Out.Text;
            }
            else
            if (radioButtonP1.Checked == false)
            {
                txtBox_P1Out.Text = null;
            }

推荐答案

使用选中属性为 false

use checked property to false
radioButton1.Checked = false;


这篇关于如何使用“clear”取消选中radiobutton?按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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