C# 初始Winform--2
2016-02-19 16:47
609 查看
一、友好提示
二、获得文本框的值
string name = txtName.Text.Trim();
string pwd = txtPwd.Text.Trim();
三、判断文本值是否为空
if (name.Equals(string.Empty))
{
MessageBox.Show("请输入用户名", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
//获得光标
this.txtName.Focus();
return;
}
if (pwd.Equals(string.Empty))
{
MessageBox.Show("请输入密码", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
//获得光标
this.txtPwd.Focus();
return;
}
四、窗体之间跳转并传值
五、关闭窗体
//1) MessageBox.Show("text提示的消息"); //MessageBox.Show("登录!"); //2) MessageBox.Show(text提示的消息,caption标题); // MessageBox.Show("确定登录", "登录提示"); //3)MessageBox.Show(text提示的消息, caption标题,按钮类型); // MessageBox.Show("确定登录", "登录提示",MessageBoxButtons.YesNo); //4)MessageBox.Show(text提示的消息, caption标题,按钮类型,消息图标); // MessageBox.Show("确定登录", "登录提示", MessageBoxButtons.YesNo,MessageBoxIcon.Error);
二、获得文本框的值
string name = txtName.Text.Trim();
string pwd = txtPwd.Text.Trim();
三、判断文本值是否为空
if (name.Equals(string.Empty))
{
MessageBox.Show("请输入用户名", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
//获得光标
this.txtName.Focus();
return;
}
if (pwd.Equals(string.Empty))
{
MessageBox.Show("请输入密码", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
//获得光标
this.txtPwd.Focus();
return;
}
四、窗体之间跳转并传值
//直接跳转到第二窗体 //FrmColor frm = new FrmColor(); ////如何将第一个窗体的值传到第二个窗体上 //frm.username = name; ////窗体显示 //frm.Show(); //将第一个窗体隐藏++>假象,不能正真退出!!!! ===??? // this.Hide(); //同时关闭两个窗体了!===》如何解决问题???? // this.Close();
五、关闭窗体
private void btnNo_Click(object sender, EventArgs e) { //对话框 DialogResult re= MessageBox.Show("你确定要关闭窗体?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); //判断 if (re == DialogResult.OK) { this.Close(); //关闭当前窗体 } }
相关文章推荐
- C# Static 的使用2
- c# 获取MP3和AMR文件格式的时长
- C# Static 使用
- C# 线程间操作无效: 从不是创建控件“receivemsg”的线程访问它。
- C# Lambda Expression概念浅析
- 类型
- c# winform 窗体载入时位置跳动
- C#回顾
- C#学习——构造函数和析构函数
- Windows 7下可以使用的各个命令语句+C#打开
- .NET Memeroy Profile 优化C#程序实战笔记
- 使用C#配合ArcGIS Engine进行地理信息系统开发
- C#几种异步编程
- XML序列化 C#
- C# 3D到2D投射
- C# 洗牌算法
- C#资源释放方法实例分析
- C# 中DateTime的各种使用
- C#获取泛型集合中元素的类型
- 远程桌面,RDP文件密码加密、解密算法(C#)