Как уменьшить код, который меняет свойства numericUpDown?
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked)
{
numericUpDownHPM1.Maximum = 1000;
numericUpDownHPM1.Minimum = 1;
numericUpDownHPM1.DecimalPlaces = 0;
numericUpDownHPM1.Increment = 1;
numericUpDownHPM1.Value = 100;
label101.Visible = true;
numericUpDownHPP1.Maximum = 1000;
label102.Visible = true;
numericUpDownMPM1.Maximum = 1000;
numericUpDownMPM1.Minimum = 1;
numericUpDownMPM1.DecimalPlaces = 0;
numericUpDownMPM1.Increment = 1;
numericUpDownMPM1.Value = 100;
label103.Visible = true;
numericUpDownMPP1.Maximum = 1000;
label104.Visible = true;
numericUpDownStrM1.Maximum = 1000;
numericUpDownStrM1.Minimum = 1;
numericUpDownStrM1.DecimalPlaces = 0;
numericUpDownStrM1.Increment = 1;
numericUpDownStrM1.Value = 100;
label111.Visible = true;
numericUpDownStrP1.Maximum = 1000;
label112.Visible = true;
numericUpDownDefM1.Maximum = 1000;
numericUpDownDefM1.Minimum = 1;
numericUpDownDefM1.DecimalPlaces = 0;
numericUpDownDefM1.Increment = 1;
numericUpDownDefM1.Value = 100;
label113.Visible = true;
numericUpDownDefP1.Maximum = 1000;
label114.Visible = true;
}
else
{
numericUpDownHPM1.Maximum = 10;
numericUpDownHPM1.Minimum = new decimal(new int[] { 1, 0, 0, 65536 });
numericUpDownHPM1.DecimalPlaces = 1;
numericUpDownHPM1.Increment = new decimal(new int[] { 1, 0, 0, 65536});
numericUpDownHPM1.Value = 1;
label101.Visible = false;
numericUpDownHPP1.Maximum = 99999;
label102.Visible = false;
numericUpDownMPM1.Maximum = 10;
numericUpDownMPM1.Minimum = new decimal(new int[] { 1, 0, 0, 65536 });
numericUpDownMPM1.DecimalPlaces = 1;
numericUpDownMPM1.Increment = new decimal(new int[] { 1, 0, 0, 65536 });
numericUpDownMPM1.Value = 1;
label103.Visible = false;
numericUpDownMPP1.Maximum = 65535;
label104.Visible = false;
numericUpDownStrM1.Maximum = 10;
numericUpDownStrM1.Minimum = new decimal(new int[] { 1, 0, 0, 65536 });
numericUpDownStrM1.DecimalPlaces = 1;
numericUpDownStrM1.Increment = new decimal(new int[] { 1, 0, 0, 65536 });
numericUpDownStrM1.Value = 1;
label111.Visible = false;
numericUpDownStrP1.Maximum = 255;
label112.Visible = false;
numericUpDownDefM1.Maximum = 10;
numericUpDownDefM1.Minimum = new decimal(new int[] { 1, 0, 0, 65536 });
numericUpDownDefM1.DecimalPlaces = 1;
numericUpDownDefM1.Increment = new decimal(new int[] { 1, 0, 0, 65536 });
numericUpDownDefM1.Value = 1;
label113.Visible = false;
numericUpDownDefP1.Maximum = 255;
label114.Visible = false;
}
}
Это только часть кода. Код в 10 раз больше, занимает много места.