Exemple #1
0
        private void ChangeColor(Control Txt)
        {
            Thread th = new Thread(() =>
            {
                while (Txt.Focused)
                {
                    continue;
                }
                if (string.IsNullOrEmpty(Txt.Text.Trim()))
                {
                    switch (Txt.Name)
                    {
                    case "Txt_DataSource":
                        {
                            Txt_DataSource.Text = "数据库地址";
                            Txt_DataSource.SelectAll();
                            break;
                        }

                    case "Txt_InitialCatalog":
                        {
                            Txt_InitialCatalog.Text = "数据库名";
                            Txt_InitialCatalog.SelectAll();
                            break;
                        }

                    case "Txt_UserID":
                        {
                            Txt_UserID.Text = "用户名";
                            Txt_UserID.SelectAll();
                            break;
                        }

                    case "Txt_Password":
                        {
                            Txt_Password.Text = "密码";
                            Txt_Password.SelectAll();
                            break;
                        }
                    }
                    Txt.ForeColor = Color.Silver;
                }
                else
                {
                    if (Equals(Txt.Text.Trim(), "数据库地址") || Equals(Txt.Text.Trim(), "数据库名") || Equals(Txt.Text.Trim(), "用户名") || Equals(Txt.Text.Trim(), "密码"))
                    {
                        Txt.ForeColor = Color.Silver;
                    }
                    else
                    {
                        Txt.ForeColor = Color.Black;
                    }
                }
            });

            th.IsBackground = true;
            th.Start();
        }
Exemple #2
0
 private void Txt_DataSource_Click(object sender, EventArgs e)
 {
     Txt_DataSource.SelectAll();
 }