zoukankan      html  css  js  c++  java
  • Button,CheckBox,Lable,RadioButton,ComboBox,TextBox六个简单控件的使用

    所有文字的更改全部在Text属性中更改!

    ComboBox:点击右上方小箭头,选择编辑项弹出:

      

    RadioButton:,Checked属性选择True,表示已被选中;

    Button:在设计中双击按钮跳转到代码区,代码中会增加如下代码:

    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 _6个简单控件_肯德基点餐
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                //主食索引默认为0
                comboBox1.SelectedIndex = 0;
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
    
            }
    
            private void radioButton1_CheckedChanged(object sender, EventArgs e)
            {
    
            }
    
            private void radioButton3_CheckedChanged(object sender, EventArgs e)
            {
    
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                //选取主食
                string zs = comboBox1.SelectedItem.ToString();
                //选取配菜
                string pc="";
                if (radioButton1.Checked)//选中的是薯条
                    pc = "薯条";
                else if(radioButton2.Checked)//选中的是土豆泥
                    pc="土豆泥";
                else//选中的是玉米棒
                    pc = "玉米棒";
                //选取饮品
                string yp = "";
                if (checkBox1.Checked)//选中可乐
                {
                    yp += checkBox1.Text;
                    if (checkBox2.Checked)//选中可乐,咖啡
                    {
                        yp =yp +"," + checkBox2.Text;
                        if (checkBox3.Checked)//选中可乐,咖啡,橙汁
                        {
                            yp =yp+ "," + checkBox3.Text;
    
                        }
                    }
                    if (checkBox3.Checked)//选中可乐,橙汁
                    {
                        yp = yp + "," + checkBox3.Text;
    
                    }
    
                }
                else if (checkBox2.Checked)//选中咖啡
                {
                    yp += checkBox2.Text;
                    if (checkBox3.Checked)//选中咖啡,橙汁
                    {
                        yp =yp+ "," + checkBox3.Text;
    
                    }
                }
                else//只选中橙汁
                {
                    yp += checkBox3.Text;
                }
    
                //获取地址
                string dz = textBox1.Text;
                //获取电话
                string dh = textBox2.Text;
                //弹出消息框
                MessageBox.Show("您选取的主食是:"+zs+"
    配菜是:"+pc+"
    饮品是:"+yp+"
    配送地址:"+dz+"
    联系方式:"+dh);
            }
        }
    }

    点击下单弹出:

  • 相关阅读:
    最新28个很棒的 jQuery 教程
    NetBeans 为PHP添加调试功能
    HTML5 存储API介绍
    PHP 变量判断
    jquery 与其它js 框架的解决办法
    从按下电源开关到bash提示符
    tar、gzip、unzip命令的详细使用方法
    Top命令中Load Average的含义
    Linux(BASH)命令搜索机制
    分析df和du的区别
  • 原文地址:https://www.cnblogs.com/maxin991025-/p/6132263.html
Copyright © 2011-2022 走看看