Form1.cs 1003 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace WindowsFormsRadioButton
  11. {
  12. public partial class Form1 : Form
  13. {
  14. public Form1()
  15. {
  16. InitializeComponent();
  17. }
  18. private void radioButton2_Click(object sender, EventArgs e)
  19. {
  20. if(radioButton2.Checked == true)
  21. {
  22. MessageBox.Show("RadioButton2控件被选中");
  23. }
  24. }
  25. private void radioButton1_Click(object sender, EventArgs e)
  26. {
  27. if (radioButton1.Checked == true)
  28. {
  29. MessageBox.Show("RadioButton1控件被选中");
  30. }
  31. }
  32. private void Form1_Load(object sender, EventArgs e)
  33. {
  34. radioButton1.Checked = false;
  35. radioButton2.Checked = false;
  36. }
  37. }
  38. }