C#基础入门 十一
2021-02-13 05:21
标签:实现 username code inf trim box alt 订票 mes 复选框的应用--问卷调查 列表框 组合框 C#基础入门 十一 标签:实现 username code inf trim box alt 订票 mes 原文地址:https://www.cnblogs.com/senlinmilelu/p/8463670.htmlC#基础入门 十一
复选框
private void buttonOK_Click(object sender, EventArgs e)
{
string sex = "";
if (rdlmale.Checked)
{
sex = "男";
}
else
{
sex = "女";
}
string traffic = "";
if (checkBox1.Checked)
{
traffic += " " + checkBox1.Text;
}
if (checkBox2.Checked)
{
traffic += " " + checkBox2.Text;
}
if (checkBox3.Checked)
{
traffic += " " + checkBox3.Text;
}
if (checkBox4.Checked)
{
traffic += " " + checkBox4.Text;
}
if (checkBox5.Checked)
{
traffic += " " + checkBox5.Text;
}
if (checkBox6.Checked)
{
traffic += " " + checkBox6.Text;
}
if (checkBox7.Checked)
{
traffic += " " + checkBox7.Text;
}
if (checkBox8.Checked)
{
traffic += " " + checkBox8.Text;
}
MessageBox.Show("您的性别是:" + sex + ",您下班后乘坐的交通工具是:" + traffic);
}
列表选择控件
private void buttonLtoR_Click(object sender, EventArgs e)
{
if (lstCityLeft.SelectedIndex
private void cboProc_SelectedIndexChanged(object sender, EventArgs e)
{
//判断组合框中选定项的索引值,根据索引值把相应的城市添加到列表框中
switch (cboProc.SelectedIndex)
{
case 0:
listcity.Items.Clear();//清空列表框中的内容
listcity.Items.Add("哈尔滨");
listcity.Items.Add("佳木斯");
listcity.Items.Add("牡丹江");
listcity.Items.Add("齐齐哈尔");
listcity.Items.Add("大庆");
break;
case 1:
listcity.Items.Clear();//清空列表框中的内容
listcity.Items.Add("沈阳");
listcity.Items.Add("大连");
listcity.Items.Add("鞍山");
listcity.Items.Add("锦州");
listcity.Items.Add("抚顺");
break;
case 2:
listcity.Items.Clear();//清空列表框中的内容
listcity.Items.Add("长春");
listcity.Items.Add("四平");
listcity.Items.Add("通化");
listcity.Items.Add("松源");
break;
}
}
private void Form1_Load(object sender, EventArgs e)
{
cboProc.Items.Add("黑龙江");
cboProc.Items.Add("辽宁");
cboProc.Items.Add("吉林");
}
民航订票系统--订票系统登陆窗体
private void buttonOK_Click(object sender, EventArgs e)
{
if (this.username.Text.Trim().Equals(string.Empty))
{
MessageBox.Show("请输入用户名!");
}
else if (this.password.Text.Trim().Equals(string.Empty))
{
MessageBox.Show("请输入密码!");
}
else if (this.loginType.Text.Trim().Equals(string.Empty))
{
MessageBox.Show("请选择登录类型!");
}
else
{
MessageBox.Show("您输入的用户名或密码不正确!", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void buttonCancel_Click(object sender, EventArgs e)
{
this.Close();
}