filetextbox.cs

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

CS
30
字号
#region Using directives

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;

#endregion

namespace UserControlLibrarySample {
  public class FileTextBox : TextBox {
    protected override void OnTextChanged(EventArgs e) {
      // If the file does not exist, color the text red
      if( !File.Exists(this.Text) ) {
        this.ForeColor = Color.Red;
      }
      else { // Make it black
        this.ForeColor = Color.Black;
      }

      // Call the base class
      base.OnTextChanged(e);
    }
  }
}

⌨️ 快捷键说明

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