⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.cs

📁 [Visual C# 2005程序设计基础教程] 全部的源码!非常经典
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Samp10_4
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            string text = "";
            foreach (object chkbox in this.groupBox1.Controls)
            {
                if (chkbox is CheckBox)
                {
                    if (((CheckBox)chkbox).Checked)
                    {
                        text += ((CheckBox)chkbox).Text + "、"; //循环获取已经被选中的控件的Text属性
                    }
                }
            }
            if (text != "")
            {
                this.label1.Text = "兴趣爱好有:" + text.Remove(text.Length - 1, 1) + "。";   //显示输出           
            }
            else
            {
                this.label1.Text = "没有被选中的内容";
            }

        }

        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {
            string text = "";
            foreach (object chkbox in this.groupBox1.Controls)
            {
                if (chkbox is CheckBox)
                {
                    if (((CheckBox)chkbox).Checked)
                    {
                        text += ((CheckBox)chkbox).Text + "、"; //循环获取已经被选中的控件的Text属性
                    }
                }
            }
            if (text != "")
            {
                this.label1.Text = "兴趣爱好有:" + text.Remove(text.Length - 1, 1) + "。";   //显示输出           
            }
            else
            {
                this.label1.Text = "没有被选中的内容";
            }

        }

        private void checkBox3_CheckedChanged(object sender, EventArgs e)
        {
            string text = "";
            foreach (object chkbox in this.groupBox1.Controls)
            {
                if (chkbox is CheckBox)
                {
                    if (((CheckBox)chkbox).Checked)
                    {
                        text += ((CheckBox)chkbox).Text + "、"; //循环获取已经被选中的控件的Text属性
                    }
                }
            }
            if (text != "")
            {
                this.label1.Text = "兴趣爱好有:" + text.Remove(text.Length - 1, 1) + "。";   //显示输出           
            }
            else
            {
                this.label1.Text = "没有被选中的内容";
            }

        }

        private void checkBox4_CheckedChanged(object sender, EventArgs e)
        {
            string text = "";
            foreach (object chkbox in this.groupBox1.Controls)
            {
                if (chkbox is CheckBox)
                {
                    if (((CheckBox)chkbox).Checked)
                    {
                        text += ((CheckBox)chkbox).Text + "、"; //循环获取已经被选中的控件的Text属性
                    }
                }
            }
            if (text != "")
            {
                this.label1.Text = "兴趣爱好有:" + text.Remove(text.Length - 1, 1) + "。";   //显示输出           
            }
            else
            {
                this.label1.Text = "没有被选中的内容";
            }

        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            RadioButton rb = sender as RadioButton;
            if (rb.Checked)
            {
                this.label2.Text = "性格为:" + rb.Text;  //利用Label2显示输出
            }

        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            RadioButton rb = sender as RadioButton;
            if (rb.Checked)
            {
                this.label2.Text = "性格为:" + rb.Text;  //利用Label2显示输出
            }

        }

        private void radioButton3_CheckedChanged(object sender, EventArgs e)
        {
            RadioButton rb = sender as RadioButton;
            if (rb.Checked)
            {
                this.label2.Text = "性格为:" + rb.Text;  //利用Label2显示输出
            }

        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -