1. 登錄界面的效果圖
2. 登錄界面實(shí)現(xiàn)的功能描述
登陸界面有2種登陸方式,操作簡(jiǎn)單快捷框弛,清晰明了貌踏,使軟件增加實(shí)用性。
3. 登錄界面各控件的參數(shù)設(shè)置
控件A:Form1
屬性 |
值 |
FormBorderStyle |
FixdeSingle |
MaximizeBox |
False |
MinimizeBox |
False |
控件B:Lable1
控件B:Lable2
控件C:Lable3
控件D:Lable3
E:TextBox1
屬性 |
值 |
MaxLength |
9 |
TabIndex |
6 |
F:TextBox2
屬性 |
值 |
MaxLength |
7 |
TabIndex |
6 |
PasswordChar |
* |
控件G:ConboBox
屬性 |
值 |
Text |
收銀員/庫(kù)管員 |
DropDownStyle |
DropDownList |
TabIndex |
5 |
控件H:Button1
控件I:Button2
控件J:LinkLable
屬性 |
值 |
Text |
忘記密碼 |
TabStop |
True |
控件K:PictureBox
屬性 |
值 |
Image |
本地資源導(dǎo)入 |
SizeMode |
StretchImage |
4. 重要方法描述
4.1登錄窗口邊框固定,且不能最大最小化
在Form窗口下,右擊屬性,在FormBorderStyle中選擇FixdeSingle;將MaximizeBox和MinimizeBox設(shè)置為False.
4.2 登錄時(shí),用戶類型不能外部重新輸入,且默認(rèn)為"收銀員"
在ComboBox的屬性中,DropDownStyle中選擇DropDownList;在窗口中雙擊進(jìn)入代碼頁(yè)面,在光標(biāo)自動(dòng)定位處加入"this.comboBox1.SelectedIndex=0;"
private void Form1_Load(object sender, EventArgs e)
{
this.comboBox1.SelectedIndex = 0;
}
4.3 用戶名最大長(zhǎng)度為9個(gè)字符,密碼不可見
在用戶名對(duì)應(yīng)的TextBox控件中,將MaxLength值設(shè)置為9;
在密碼對(duì)應(yīng)的TextBox控件中,將PasswordCha設(shè)置為*
4.4 當(dāng)點(diǎn)擊退出按鈕時(shí),自動(dòng)退出登錄界面
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
5. 想一想丧蘸,還有哪些尚需完善的功能
5.1 輸入用戶名后回車, 光標(biāo)跳轉(zhuǎn)到密碼輸入框(涉及到KeyPres事件 和Tab鍵順序)
在TextBox1屬性中點(diǎn)擊事件(閃電圖標(biāo)),找到KeyPress雙擊進(jìn)入代碼頁(yè)面添加代碼
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
SendKeys.Send("{Tab}");
}
}
5.2 輸入密碼后回車,則直接登錄(涉及到TextBox的KeyPres事件)
在TextBox2屬性中點(diǎn)擊事件(閃電圖標(biāo)),找到KeyPress雙擊進(jìn)入代碼頁(yè)面添加代碼
private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
this.button1_Click(sender ,e);
}
}
5.3 按Tab進(jìn)入輸入框時(shí),自動(dòng)全選(涉及到TextBox的Enter事件)
在TextBox1和TextBox2屬性中點(diǎn)擊事件(閃電圖標(biāo)),找到Enter雙擊進(jìn)入代碼頁(yè)面分別添加代碼
private void textBox1_Enter(object sender, EventArgs e)
{
((TextBox)sender).SelectAll();
}
private void textBox2_Enter(object sender, EventArgs e)
{
((TextBox)sender).SelectAll();
}