Form2.cs
上传用户:linger1010
上传日期:2008-12-08
资源大小:561k
文件大小:1k
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- namespace DataTransport
- {
- public partial class Form2 : Form
- {
- public Form2(string defaultUser)
- {
- InitializeComponent();
- m_txtUserName.Text = defaultUser;
- }
- private void m_btnLogin_Click(object sender, EventArgs e)
- {
- if(this.Login != null)
- this.Login(this, new LoginEventArgs(m_txtUserName.Text));
- this.DialogResult = DialogResult.OK;
- }
- private void m_btnCancel_Click(object sender, EventArgs e)
- {
- this.DialogResult = DialogResult.Cancel;
- }
- #region 使用属性
- public string UserName
- {
- get
- {
- return m_txtUserName.Text;
- }
- set
- {
- if(value == null)
- m_txtUserName.Text = String.Empty;
- else
- m_txtUserName.Text = value;
- }
- }
- #endregion
- #region 使用事件
- public event LoginEventHandler Login;
- public class LoginEventArgs : EventArgs
- {
- string m_userName;
- public string UserName
- {
- get
- {
- return m_userName;
- }
- set
- {
- if(value != null)
- m_userName = value;
- else
- m_userName = String.Empty;
- }
- }
- public LoginEventArgs(string userName)
- {
- this.UserName = userName;
- }
- }
- public delegate void LoginEventHandler(object sender, LoginEventArgs e);
- #endregion
- }
- }