📄 qtextbox.cs
字号:
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Drawing;
namespace Qeb.Control
{
public partial class QTextBox : System.Windows.Forms.TextBox
{
private string m_LookUpPrompt = "";
private Color oldColor = Color.Black;
public QTextBox()
{
InitializeComponent();
oldColor = this.ForeColor;
}
public QTextBox(IContainer container)
{
container.Add(this);
InitializeComponent();
oldColor = this.ForeColor;
}
/// <summary>
/// 快速定位提示
/// </summary>
[Description("快速定位提示"), Category("自定义属性")]
public string LoopUpPrompt
{
get { return m_LookUpPrompt; }
set
{
if (value == null || value == "")
{
m_LookUpPrompt = "";
this.SetLookUpPrompt(false);
}
else
{
m_LookUpPrompt = value;
if (!this.Focused)
{
SetLookUpPrompt(true);
}
}
}
}
private void SetLookUpPrompt(bool show)
{
if (show)
{
this.Text = this.m_LookUpPrompt;
this.ForeColor = Color.Silver;
}
else
{
if (this.Text == this.m_LookUpPrompt)
{
this.ForeColor = oldColor;
this.Text = "";
}
}
}
protected override void OnEnter(EventArgs e)
{
base.OnEnter(e);
if (this.m_LookUpPrompt != "" && this.Text == this.m_LookUpPrompt)
{
this.SetLookUpPrompt(false);
}
}
protected override void OnLeave(EventArgs e)
{
base.OnLeave(e);
if (this.m_LookUpPrompt != "" && this.Text == "")
{
this.SetLookUpPrompt(true);
}
}
protected override void OnTextChanged(EventArgs e)
{
if (this.m_LookUpPrompt == "")
base.OnTextChanged(e);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -