Я хотел бы использовать переменную в нескольких функциях в Visual Studio. Я пытаюсь получить value_1 , который будет использоваться в качестве метки для private void button1_Click .
Если я попробую это так, я получу следующее сообщение об ошибке:
'Black1_CheckedChanged' соответствует делегату 'EventHandler'
Что мне не хватает?
Буду очень признателен за помощь. Спасибо.
public partial class Form1 : Form
{
int value_1 = 20;
int value_2 = 20;
int value_3 = 20;
public Form1()
{
InitializeComponent();
}
// Groupe Colour 1
private void Black1_CheckedChanged(object sender, EventArgs e, int value_1)
{
colour1.BackColor = System.Drawing.Color.Black;
groupBox1.BackColor = System.Drawing.Color.Black;
value_1 = 0;
}
private void Brown1_CheckedChanged(object sender, EventArgs e)
{
colour1.BackColor = System.Drawing.Color.Brown;
groupBox1.BackColor = System.Drawing.Color.Brown;
value_1 = 1;
}
private void Red1_CheckedChanged(object sender, EventArgs e)
{
colour1.BackColor = System.Drawing.Color.Red;
groupBox1.BackColor = System.Drawing.Color.Red;
value_1 = 2;
}
private void Orange1_CheckedChanged(object sender, EventArgs e)
{
colour1.BackColor = System.Drawing.Color.Orange;
groupBox1.BackColor = System.Drawing.Color.Orange;
value_1 = 3;
}
private void Yellow1_CheckedChanged(object sender, EventArgs e)
{
colour1.BackColor = System.Drawing.Color.Yellow;
groupBox1.BackColor = System.Drawing.Color.Yellow;
value_1 = 4;
}
private void Green1_CheckedChanged(object sender, EventArgs e)
{
colour1.BackColor = System.Drawing.Color.Green;
groupBox1.BackColor = System.Drawing.Color.Green;
value_1 = 5;
}
private void Blue1_CheckedChanged(object sender, EventArgs e)
{
colour1.BackColor = System.Drawing.Color.Blue;
groupBox1.BackColor = System.Drawing.Color.Blue;
value_1 = 6;
}
private void Purple1_CheckedChanged(object sender, EventArgs e)
{
colour1.BackColor = System.Drawing.Color.Purple;
groupBox1.BackColor = System.Drawing.Color.Purple;
value_1 = 7;
}
private void Grey1_CheckedChanged(object sender, EventArgs e)
{
colour1.BackColor = System.Drawing.Color.Gray;
groupBox1.BackColor = System.Drawing.Color.Gray;
value_1 = 8;
}
private void White1_CheckedChanged(object sender, EventArgs e)
{
colour1.BackColor = System.Drawing.Color.White;
groupBox1.BackColor = System.Drawing.Color.White;
value_1 = 9;
}
private void button1_Click(object sender, EventArgs e)
{
value_1 = int.Parse(label_total.Text);
}
}