你的按钮里面有没有写代码
this.close()??
this.close()??
解决方案 »
- access文件大小的问题?
- System.Web.HttpException: SaveAs 方法被配置为需要根路径,但是路径“personal/201101-14\”不是根路径。
- 请教C#(winFrom)高手,关于动态加载picturebox的问题?急!!
- c# 如何在一大串的字符串中找到并反蓝指定字符(指定字符可能出现多次)?
- 求解:C#主窗体隐藏了,如何在子窗体里让它在显示???
- C#连接数据库失败怎么办
- [DllImport("user32.dll")]?
- 谁有VS.NET UML建模高级编程电子文档
- new一个socket在不同版本.net下的问题
- Charts控件,怎么显示特定点位的文本Lable??
- 高分求好的界面和表格控件
- 框架问题求助???
如是应该
在打开按钮事件里写
rr yy=new rr();
if(yy.ShowDialog(this)==DialogResult.OK)
{
//执行的操作
}
yy.Dispose();
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using FzService.Class;namespace FzService
{
/// <summary>
/// frmLogin 的摘要说明。
/// </summary>
public class frmLogin : System.Windows.Forms.Form
{
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.ComboBox cmbUsers;
private System.Windows.Forms.TextBox txtPass;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button btnOk;
private System.Windows.Forms.Button btnCancel;
private string userid;
private Public pc;
public string UserID
{
get
{
return userid;
}
set
{
userid=value;
}
}
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null; public frmLogin()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmLogin));
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label1 = new System.Windows.Forms.Label();
this.txtPass = new System.Windows.Forms.TextBox();
this.cmbUsers = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.btnOk = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
this.label1,
this.txtPass,
this.cmbUsers,
this.label2});
this.groupBox1.Location = new System.Drawing.Point(7, 0);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(289, 104);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "登录信息";
this.groupBox1.Enter += new System.EventHandler(this.groupBox1_Enter);
//
// label1
//
this.label1.Location = new System.Drawing.Point(32, 32);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 16);
this.label1.TabIndex = 2;
this.label1.Text = "用户名:";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtPass
//
this.txtPass.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtPass.Location = new System.Drawing.Point(96, 64);
this.txtPass.Name = "txtPass";
this.txtPass.PasswordChar = '#';
this.txtPass.Size = new System.Drawing.Size(144, 21);
this.txtPass.TabIndex = 1;
this.txtPass.Text = "";
//
// cmbUsers
//
this.cmbUsers.Location = new System.Drawing.Point(96, 28);
this.cmbUsers.Name = "cmbUsers";
this.cmbUsers.Size = new System.Drawing.Size(144, 20);
this.cmbUsers.TabIndex = 0;
this.cmbUsers.Text = "选择用户";
//
// label2
//
this.label2.Location = new System.Drawing.Point(32, 69);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(56, 16);
this.label2.TabIndex = 2;
this.label2.Text = "口 令:";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// btnOk
//
this.btnOk.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnOk.Location = new System.Drawing.Point(120, 110);
this.btnOk.Name = "btnOk";
this.btnOk.TabIndex = 1;
this.btnOk.Text = "确定";
this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
//
// btnCancel
//
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnCancel.Location = new System.Drawing.Point(216, 110);
this.btnCancel.Name = "btnCancel";
this.btnCancel.TabIndex = 2;
this.btnCancel.Text = "取消";
//
// frmLogin
//
this.AcceptButton = this.btnOk;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(306, 135);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.btnCancel,
this.btnOk,
this.groupBox1});
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "frmLogin";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "用户登录";
this.Load += new System.EventHandler(this.frmLogin_Load);
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false); }
#endregion
#region 自定义方法
/// <summary>
/// 将用户列表绑定到cmbUser
/// </summary>
private void LoadUser()
{
try
{
pc=new Public();
DataView dv=new DataView();
dv=pc.UserEmailList("用户").Tables[0].DefaultView;
dv.RowFilter="生效=1";
this.cmbUsers.DataSource=dv;
this.cmbUsers.DisplayMember="用户名";
}
catch(System.Exception ee)
{
if(MessageBox.Show(ee.Message,this.Text,MessageBoxButtons.RetryCancel,MessageBoxIcon.Warning)==DialogResult.Retry)
LoadUser();
} }
#endregion private void frmLogin_Load(object sender, System.EventArgs e)
{
LoadUser();
} private void btnOk_Click(object sender, System.EventArgs e)
{
if(this.txtPass.Text=="")
MessageBox.Show("请输入用户口令!");
else
{
userid=pc.UserLogin(this.cmbUsers.Text,this.txtPass.Text.Trim());
if(userid!=null)
this.DialogResult=DialogResult.OK;
else
{
MessageBox.Show("用户名或口令错误!",this.Text,MessageBoxButtons.OK,MessageBoxIcon.Warning);
this.txtPass.Focus();
}
}
} private void groupBox1_Enter(object sender, System.EventArgs e)
{
}
}
}