using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace KSpring.Component.DGVForEdit.TextBoxForDGV
{
public class TextBoxForDGV : TextBox
{
private ToolTip toolTip1;
private System.ComponentModel.IContainer components;
string _tempStr = "请输入";
public TextBoxForDGV()
{
InitializeComponent();
this.Enter += new EventHandler(TextBoxForDGV_Enter);
this.TextChanged += new EventHandler(TextBoxForDGV_TextChanged);
this.Leave += new EventHandler(TextBoxForDGV_Leave);
}
void TextBoxForDGV_Leave(object sender, EventArgs e)
{
this.toolTip1.Hide(this);
}
void TextBoxForDGV_TextChanged(object sender, EventArgs e)
{
int _i = 0;
if (int.TryParse(Text, out _i) == false)
{
_tempStr = "不是数字";
}
else
{
if (Text.Trim().Length != 10)
{
_tempStr = "你输入了" + Text.Trim().Length + "位,还差" + (10 - Text.Trim().Length);
}
else
{
_tempStr = "输入正确";
}
}
this.toolTip1.Show(_tempStr, this);
}
void TextBoxForDGV_Enter(object sender, EventArgs e)
{
this.toolTip1.Show(_tempStr, this);
}
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.SuspendLayout();
//
// toolTip1
//
this.toolTip1.ShowAlways = true;
this.ResumeLayout(false);
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
}
}
}