75 lines
1.7 KiB
C#
75 lines
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace WinFormsLibrary
|
|
{
|
|
public partial class NumberTextBox : UserControl
|
|
{
|
|
public int? maxValue = null;
|
|
public int? minValue = null;
|
|
public bool error = false;
|
|
|
|
public NumberTextBox()
|
|
{
|
|
InitializeComponent();
|
|
|
|
}
|
|
|
|
public int? MinValue
|
|
{
|
|
get { return minValue; }
|
|
set
|
|
{
|
|
if (value == null) return;
|
|
minValue = value;
|
|
numericUpDown.Minimum = (int)value;
|
|
}
|
|
}
|
|
|
|
public int? MaxValue
|
|
{
|
|
get { return maxValue; }
|
|
set
|
|
{
|
|
if (value == null) return;
|
|
maxValue = value;
|
|
numericUpDown.Maximum = (int)value;
|
|
}
|
|
}
|
|
|
|
public decimal Value
|
|
{
|
|
get { return numericUpDown.Value; }
|
|
set
|
|
{
|
|
if (MinValue == null || MaxValue == null)
|
|
{
|
|
error = true;
|
|
return;
|
|
}
|
|
|
|
if (value < MinValue || value > MaxValue)
|
|
{
|
|
error = true;
|
|
return;
|
|
}
|
|
|
|
numericUpDown.Value = value;
|
|
}
|
|
}
|
|
|
|
public event EventHandler DateChanged
|
|
{
|
|
add { numericUpDown.ValueChanged += value; }
|
|
remove { numericUpDown.ValueChanged -= value; }
|
|
}
|
|
}
|
|
}
|