formtextbox.cs

来自「csharp课本的源代码」· CS 代码 · 共 43 行

CS
43
字号
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace TextBoxExample
{
    public partial class FormTextBox : Form
    {
        public FormTextBox()
        {
            InitializeComponent();
        }

        private void textBoxUser_MouseEnter(object sender, EventArgs e)
        {
            textBoxUser.Text = "";
        }

        private void textBoxPassword_TextChanged(object sender, EventArgs e)
        {
            textBoxUser.ReadOnly = true;
        }

        private void textBoxInformation_TextChanged(object sender, EventArgs e)
        {
            buttonOK.ForeColor = System.Drawing.Color.Red;
            buttonOK.Size = new System.Drawing.Size(100, 50);

        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            labelResult.Visible = true;
            labelResult.Text = string.Format("用户名是:{0}; 密码是:{1}\n输入的资料是:\n{2}",
               textBoxUser.Text, textBoxPassword.Text, textBoxInformation.Text);

        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?