C#窗体应用程序之 单选按钮与分组框 源代码

来源:互联网 发布:去视频马赛克软件 编辑:程序博客网 时间:2024/06/05 06:08
using System.Windows.Forms;
using System.Drawing;
using System;
namespace lx21
{
    public partial class Form2 : Form
    {
        //private Label LSex;
       // private Label LMarry;
        private GroupBox gbSex;
        private GroupBox gbMarry;
        private RadioButton rbMan;
        private RadioButton rbWomen;
        private RadioButton rbMarried;
        private RadioButton rbSignal;
        private Button btnOK;


        public Form2()
        {
            InitializeComponent();
        }
        private void InitializeComponent()
        {
           // this.LSex = new Label();
           // this.LMarry = new Label();
            this.gbSex = new GroupBox();
            this.gbMarry = new GroupBox();
            this.rbMan = new RadioButton();
            this.rbMarried = new RadioButton();
            this.rbSignal = new RadioButton();
            this.rbWomen = new RadioButton();
            this.btnOK = new Button();


            //this.ClientSize = new System.Drawing.Size(350, 225);
            this.ClientSize = new System.Drawing.Size(500,300);
            this.Text = "99问答";


            //this.LSex.Location = new Point(50, 50);
            //this.LSex.Size = new Size(50,50);
            //this.LSex.TabIndex = 0;
            //this.LSex.Text = "* 性别";
            this.gbSex.Location = new Point(50, 50);
            this.gbSex.Size = new Size(150, 160);
            this.gbSex.TabStop = false;
            this.gbSex.Text = "* 性别";


            //this.LMarry.Location = new Point(250, 50);
            //this.LMarry.Size = new Size(50,50);
            //this.LMarry.TabIndex = 1;
            //this.LMarry.Text = "* 婚否";
            this.gbMarry.Location = new Point(250, 50);
            this.gbMarry.Size = new Size(150, 160);
            this.gbMarry.TabStop = false;
            this.gbMarry.Text = "* 婚否";


            this.rbMan.Location = new Point(50, 50);
            this.rbMan.Size = new Size(50,50);
            this.rbMan.TabIndex = 2;
            this.rbMan.Text = "男";


            this.rbWomen.Location = new Point(50, 90);
            this.rbWomen.Size = new Size(50, 50);
            this.rbWomen.TabIndex = 3;
            this.rbWomen.Text = "女";


            this.rbSignal.Location = new Point(50, 50);
            this.rbSignal.Size = new Size(50, 50);
            this.rbSignal.TabIndex = 4;
            this.rbSignal.Text = "未婚";


            this.rbMarried.Location = new Point(50, 90);
            this.rbMarried.Size = new Size(50,  50);
            this.rbMarried.TabIndex = 5;
            this.rbMarried.Text = "已婚";


            this.btnOK.Location = new Point(200, 249);
            this.btnOK.Size = new Size(50,25);
            this.btnOK.TabIndex = 6;
            this.btnOK.Text = "提交";
            this.btnOK.Click += new EventHandler(this.btnOK_Click);


            //this.Controls.Add(LSex);
            //this.Controls.Add(LMarry);
            this.Controls.Add(gbSex);
            this.Controls.Add(gbMarry);


            //this.Controls.Add(rbMan);
            //this.Controls.Add(rbWomen);
            //this.Controls.Add(rbMarried);
            //this.Controls.Add(rbSignal);
            this.gbSex.Controls.Add(rbMan);
            this.gbSex.Controls.Add(rbWomen);
            this.gbMarry.Controls.Add(rbMarried);
            this.gbMarry.Controls.Add(rbSignal);
            this.Controls.Add(btnOK);
        }


        private void btnOK_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }


        static void Main()
        {
            Application.Run(new Form2());
        }
    }
}
0 0
原创粉丝点击