1 using System;
2 using System.Drawing;
3 using System.Windows.Forms;
4
5 namespace 案例演示
6 {
7 public partial class frmlogo : Form
8 {
9 public frmlogo()
10 {
11 InitializeComponent();
12 }
13 int usi,pwi;
14 private void frmlogo_Load(object sender, EventArgs e)
15 {
16
17 }
18
19 private void textBox1_MouseDown(object sender, MouseEventArgs e)
20 {
21 usi++;
22 if (usi==1)
23 {
24 textBox1.Text = "";
25 }
26 if (textBox2.Text=="")
27 {
28 pwi = 0;
29 textBox2.Text = "密码";
30 }
31
32
33 }
34
35 private void textBox2_MouseDown(object sender, MouseEventArgs e)
36 {
37 pwi++;
38 if (textBox1.Text=="")
39 {
40 textBox1.Text = "用户名";
41 usi = 0;
42 }
43 if (pwi==1)
44 {
45 textBox2.Text = "";
46 }
47 }
48
49 private void textBox1_KeyDown(object sender, KeyEventArgs e)
50 {
51 textBox1.ForeColor = Color.Black;
52 }
53
54 private void textBox2_KeyDown(object sender, KeyEventArgs e)
55 {
56 textBox2.ForeColor = Color.Black;
57 }
58
59 private void button1_Click(object sender, EventArgs e)
60 {
61
62 }
63 }
64 }
65
66 2017-09-02