using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms; namespace Common
{
/// <summary>
/// TextBox控件操作类
/// </summary>
public class CtlTextBoxOperate
{
private TextBox m_textBox = null; /// <summary>
/// TextBox控件
/// </summary>
public TextBox refTextBoxControl
{
set
{
m_textBox = value;
}
get
{
return m_textBox;
}
} /// <summary>
/// 构造函数
/// </summary>
public CtlTextBoxOperate()
{
} private static volatile CtlTextBoxOperate m_tbOpera = null;
/// <summary>
///获取操作TextBox控件的单一实例
/// </summary>
public static CtlTextBoxOperate GetInstance()
{
if(null == m_tbOpera)
{
m_tbOpera = new CtlTextBoxOperate();
}
return m_tbOpera;
} /// <summary>
/// 只能输入整数!
/// </summary>
/// <param name="e"></param>
public void InputIntDigit(KeyPressEventArgs e)
{
if ((e.KeyChar < 48 || e.KeyChar > 57) && (e.KeyChar != 8)) //48代表0,57代表9,8代表空格,46代表小数点
{
e.Handled = true;
}
}
/// <summary>
/// 只能输入数!
/// </summary>
/// <param name="e"></param>
public void InputDigit(KeyPressEventArgs e)
{
if ((e.KeyChar < 48 || e.KeyChar > 57) && (e.KeyChar != 8) && e.KeyChar != 46) //48代表0,57代表9,8代表空格,46代表小数点
{
e.Handled = true;
}
}
}
}