Radio button checked changed event fires twice

后端 未结 7 1015
梦谈多话
梦谈多话 2020-12-03 16:52

Please read my question its not a duplicate one.

I\'ve three radio buttons on windows form and all these buttons have common \'CheckedChanged\' event associated. Whe

7条回答
  •  星月不相逢
    2020-12-03 17:18

    {
        public partial class Form3 : Form
        {
            public Form3()
            {
                InitializeComponent();
            }
            int click = 0;
            private void radioButton1_Click(object sender, EventArgs e)
            {
                click++;
                if (click %2==1)
                {
                    radioButton1.Checked = true;
                }
                if (click %2==0)
                {
                    radioButton1.Checked = false;
                }
                if (radioButton1.Checked==true)
                {
                    label1.Text = "Cheked";
                }
                if (radioButton1.Checked==false)
                {
                    label1.Text = "Uncheked";
                }
            }
    
        }
    }
    

提交回复
热议问题