点餐用到的控件:
1)TabControl: 管理并向用户显示可以包含控件和组件的相关选项卡的信息
2)ComboBox: 显示一个可编辑的文本框,其中包含一个允许值下拉列表
3)DateTimePicker: 允许用户设定日期和时间,并以指定的格式显示日期和时间
4)CheckBox: 允许用户选择和清除关联选项
5)TextBox:汇总信息 ScrollBars属性(一般设置为Vertical)
6)GroupBox: 在一组控件周围显示一个带有可选标题的框架
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 TabControl
{public partial class Form1 : Form{public Form1(){InitializeComponent();txtSex.SelectedIndex = 0; //设置性别初始值}private void btnNext01_Click(object sender, EventArgs e){tabControl1.SelectedIndex = 1;//设置下一页为当前页}private void btnNext02_Click(object sender, EventArgs e){tabControl1.SelectedIndex = 2; //设置下一页为当前页//调用显示信息方法ShowInfo();}private void ShowInfo() {txtinfo.Text = "";//先清空//非法数据处理if(txt_name.Text.Trim().Length == 0){MessageBox.Show("请输入姓名!");return;}if (txt_phone.Text.Trim().Length == 0){MessageBox.Show("请输入电话号码!");return;}if (txtAddr.Text.Trim().Length == 0){MessageBox.Show("请输入送餐地址!");return;}string strInfo = "你的订单信息:" + "\r\n"; //定义存信息的变量strInfo += "姓名:" + txt_name.Text.Trim() + "\r\n"; //姓名strInfo += "性别:" + txtSex.Text.Trim() + "\r\n";strInfo += "手机号码:" + txt_phone.Text.Trim() + "\r\n";strInfo += "送餐地址:" + txtAddr.Text.Trim() + "\r\n";strInfo += "送餐时间:" + txtTime.Value.ToShortDateString() + " " + txtTime.Value.ToShortTimeString() + "\r\n";string strEat = "";foreach (CheckBox chkObj in txtType.Controls){if (chkObj.Checked){strEat += chkObj.Text + ",";}}if (strEat.Length == 0){MessageBox.Show("请选择至少一种餐品类型!");return;}strInfo += "餐品类型:" + strEat + "\r\n";//显示信息txtinfo.Text = strInfo;} }
}