2oe dodelal vrode

This commit is contained in:
aleyckin 2023-09-21 10:49:09 +04:00
parent c5f307ec81
commit 82f6fc6e49
2 changed files with 80 additions and 7 deletions

View File

@ -28,18 +28,32 @@
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
numericUpDown = new NumericUpDown();
((System.ComponentModel.ISupportInitialize)numericUpDown).BeginInit();
SuspendLayout();
//
// numericUpDown
//
numericUpDown.Location = new Point(117, 37);
numericUpDown.Maximum = new decimal(new int[] { 110, 0, 0, 0 });
numericUpDown.Minimum = new decimal(new int[] { 50, 0, 0, int.MinValue });
numericUpDown.Name = "numericUpDown";
numericUpDown.Size = new Size(120, 23);
numericUpDown.TabIndex = 0;
//
// NumberTextBox
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Name = "NumberTextBox";
this.Size = new System.Drawing.Size(364, 264);
this.ResumeLayout(false);
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(numericUpDown);
Name = "NumberTextBox";
Size = new Size(364, 106);
((System.ComponentModel.ISupportInitialize)numericUpDown).EndInit();
ResumeLayout(false);
}
#endregion
private NumericUpDown numericUpDown;
}
}

View File

@ -12,9 +12,68 @@ namespace WinFormsLibrary
{
public partial class NumberTextBox : UserControl
{
public int maxValue;
public int minValue;
public bool error = false;
public NumberTextBox()
{
InitializeComponent();
}
//публичное свойство
public string Selected
{
get
{
if (minValue == null)
{
error = true;
}
if (maxValue == null)
{
error = true;
}
if (Check_Value(Convert.ToInt32(numericUpDown.Value)))
{
return "";
}
return numericUpDown.Value.ToString();
}
set
{
if (!Check_Value(Convert.ToInt32(numericUpDown.Value)))
{
error = true;
}
numericUpDown.Value = 0;
}
}
public void SetMaxValue(int number) // переделать через свойство
{
numericUpDown.Maximum = number;
maxValue = number;
}
public void SetMinValue(int number) // переделать через свойство
{
numericUpDown.Minimum = number;
minValue = number;
}
public bool Check_Value(int number)
{
if (number < numericUpDown.Minimum || number > numericUpDown.Maximum)
{
return false;
}
return true;
}
}
}