You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.2 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace JwKdsV.Component
{
public partial class NumSpinners : UserControl
{
public NumSpinners()
{
InitializeComponent();
}
private decimal _defaultValue = 0;
[Category("杂项"), Description("默认值"), DefaultValue(0)]
public decimal DefaultValue
{
get
{
return _defaultValue;
}
set
{
_defaultValue = value;
this.textBox1.Text = _defaultValue + "";
}
}
[Category("杂项"), Description("步长,每次增减标准"), DefaultValue(1)]
public decimal StepValue { get; set; }
[Category("杂项"), Description("最大值"), DefaultValue(100)]
public decimal MaxValue { get; set; }
[Category("杂项"), Description("最小值"), DefaultValue(0)]
public decimal MinValue { get; set; }
public decimal NumValue
{
get
{
var test = this.textBox1.Text;
decimal value = 0;
decimal.TryParse(test, out value);
this.textBox1.Text = value + "";
return value;
}
}
/// <summary>
/// 减法
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnSubClick(object sender, EventArgs e)
{
if(this.NumValue - this.StepValue >= this.MinValue)
{
this.textBox1.Text = (this.NumValue - this.StepValue).ToString();
}
}
/// <summary>
/// 加法
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnPlusClick(object sender, EventArgs e)
{
if (this.NumValue + this.StepValue <= this.MaxValue)
{
this.textBox1.Text = (this.NumValue + this.StepValue).ToString();
}
}
}
}