日期:2012-01-28  浏览次数:20509 次

using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Diagnostics;

namespace UtilityLibrary
{
    /// <summary>
    /// Summary description for NumericTextBox.
    /// </summary>
    public class NumericTextBox : System.Windows.Forms.TextBox
    {
        private int minimum = -1;
        private int maximum = -1;
        private bool useRange = false;
        private string lastChar;
        
        public NumericTextBox()
        {
            InitializeComponent();
        }

        protected override void OnPaint(PaintEventArgs pe)
        {
            base.OnPaint(pe);
        }

        public Size SetRange
        {
            get
            {
                if ( useRange )
                    return new Size(minimum, maximum);
                else
                    return new Size(-1, -1);
            }
            set
            {
                minimum = value.Width;
                maximum = value.Height;
                useRange = true;
            }
            
        }

        private void InitializeComponent()
        {
            //
            // NumericTextBox
            //
            this.TextChanged += new System.EventHandler(this.NumericTextBox_TextChanged);
        
        }

    

        protected override void OnKeyPress(KeyPressEventArgs e)
        {