程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> C#入門知識 >> 01windows窗體程序學習,01windows窗體程序

01windows窗體程序學習,01windows窗體程序

編輯:C#入門知識

01windows窗體程序學習,01windows窗體程序


 1  
 2 
 3 靜態用戶名和密碼的登錄練習
 4 
 5 private void button2_Click(object sender, EventArgs e)   
 6 {
 7 
 8 textUser.Text = Convert.ToString(textUser.Text);
 9 textBox2.Text = textBox2.Text.ToString();
10 if (textUser.Text == "admin" && textBox2.Text == "111111")
11 {
12 MessageBox.Show("登錄成功");
13 }
14 else
15 {
16 MessageBox.Show("用戶名或密碼錯誤");
17 }
18 
19 }
20 
21  
22 
23 窗體關閉消息提示的練習
24 
25 private void Form2_FormClosing(object sender, FormClosingEventArgs e)
26 {
27 DialogResult re = MessageBox.Show("確定關閉?","消息",MessageBoxButtons.YesNo);//是否關閉消息提示框
28 if (re == DialogResult.No)
29 {
30 e.Cancel = true; //關閉
31 }
32 else
33 {
34 e.Cancel = false; //不關閉
35 }
36 }
37 
38  

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved