博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
using System;
using System.Windows.Forms;

namespace Northwind
{
    
/// <summary>
    
/// Summary description for NumericTextBox.
    
/// </summary>

    public class NumericTextBox  : TextBox
    
{
        
public NumericTextBox()
        
{
            
        }

        
        
protected override void OnKeyPress(KeyPressEventArgs e)
        
{
            
if (!char.IsDigit(e.KeyChar))
            
{
                e.Handled 
= true;
            }

        }


    }

}

使用该继承的控件,可以实现只允许输入数字.
posted on 2005-08-06 13:32  kamlau  阅读(531)  评论(0编辑  收藏  举报