highscorewhoform.cs

来自「中文名:Windows Forms 程序设计 英文名:Windows Form」· CS 代码 · 共 38 行

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

namespace Wahoo {
  public partial class HighScoreWhoForm : Form {
  
    public HighScoreWhoForm() {
      InitializeComponent();
    }

    public int Score {
      get { return int.Parse(this.scoreTextBox.Text); }
      set { this.scoreTextBox.Text = value.ToString(); }
    }

    public string PlayerName {
      get { return this.nameTextBox.Text; }
      set { this.nameTextBox.Text = value; }
    }
    
    private void nameTextBox_Validating(object sender, CancelEventArgs e) {
      string msg = null;
      if( string.IsNullOrEmpty(this.nameTextBox.Text) ) {
        msg = "Please enter a name";
      }
      this.errorProvider.SetError((Control)sender, msg);
    }

    private void okButton_Click(object sender, EventArgs e) {
      if( !this.Validate() ) this.DialogResult = DialogResult.None;
    }
  }
}

⌨️ 快捷键说明

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