⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 passwordform.cs

📁 集学生管理系统、学生选课系统、老师管理系统与一身 不错的
💻 CS
字号:
using System;
using System.Collections;
using System.Windows.Forms;
using System.Drawing;

public class PasswordForm : Form {

  private TextBox passwordTextBox; 
  private Label passwordLabel;
  private string password;

  public PasswordForm() {

    int componentTop = 15;

    // create label component
    passwordLabel = new Label();
    passwordLabel.Text = "Password:";
    passwordLabel.Top = componentTop;
    passwordLabel.Left = 15;
    passwordLabel.Width = 70;
    passwordLabel.Font = new Font(passwordLabel.Font, FontStyle.Bold);

    // Create TextBox component
    passwordTextBox = new TextBox();
    passwordTextBox.Height = 40;
    passwordTextBox.Width = 100;
    passwordTextBox.Top = componentTop;
    passwordTextBox.Left = passwordLabel.Right;
    passwordTextBox.PasswordChar = '*';

    // Assign an event handler to the SSN TextBox
    passwordTextBox.KeyUp += new KeyEventHandler(PasswordKeyUp);

    // Add the GUI components to the form
    this.Controls.Add(passwordLabel);
    this.Controls.Add(passwordTextBox);

    this.Text = "Enter Password";
    this.Height = 80;
    this.Width = 240;
    this.MinimumSize = this.Size;
    this.StartPosition = FormStartPosition.CenterScreen;
  }

  // Property
  public string Password {
    get {
      return password;
    }
  }

  // Event handling method
  public void PasswordKeyUp(object source, KeyEventArgs e) {
    if ( e.KeyCode == Keys.Enter ) {
      password = passwordTextBox.Text.Trim();
      this.Visible = false;
    }
  }

  // Test scaffold

  public static void Main(string[] args) {
    PasswordForm passwordForm = new PasswordForm();
    passwordForm.Visible = true;
    Application.Run(passwordForm);
  }
}

⌨️ 快捷键说明

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