您的位置:首页 > 其它

单选复选(喜欢)

2013-11-12 14:10 197 查看


using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;



namespace Lovely

{

    public partial class frmLovely : Form

    {

        public frmLovely()

        {

            InitializeComponent();

        }

        private void btnOne_Click(object sender, EventArgs e)

        {

            //三元运算符:  ?:

            string select = (this.rdoOne.Checked ? this.rdoOne.Text : "")

                + (this.rdoThree.Checked ? this.rdoTwo.Text : "")

                + (this.rdoThree.Checked ? this.rdoThree.Text : "")

                + (this.rdoFour.Checked ? this.rdoFour.Text : "");

            if (select.Length==0)

            {

                this.txtOne.Text="请选择!";

                return;

            }

            this.txtOne.Text = "你喜欢住的是:" + select;

        }

        private void btnTwo_Click(object sender, EventArgs e)

        {

            string select = (this.chkApple.Checked ? this.chkApple.Text + "." : "")

                + (this.checkBanana.Checked ? this.checkBanana.Text + "." : "")

                + (this.chkCoconut.Checked ? this.chkCoconut.Text + "." : "")

                + (this.chkPeach.Checked ? this.chkPeach.Text + "." : "");

            if (select.Length == 0)

            {

                this.txtTwo.Text = "请选择";

                return;

            }

            this.txtTwo.Text = "你喜欢的水果是:" + select;

        }

        private void frmLovely_Load(object sender, EventArgs e)

        {

            this.txtOne.Focus();

        }

    }

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息