Подскажите, как заставить работать выделенные в коде события:
Form1.cs
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 Курсовой_Тест
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
// Events
private void button1_MouseMove(object sender, MouseEventArgs e)
{
button1.BackColor = Color.LightGray;
}
private void button1_Click(object sender, EventArgs e)
{
Close();
}
private void button3_Click(object sender, EventArgs e)
{
WindowState = FormWindowState.Minimized;
}
private void button2_MouseLeave(object sender, EventArgs e)
{
button2.ForeColor = Color.FromArgb(230, 126, 34);
}
private void button4_MouseLeave(object sender, EventArgs e)
{
button2.ForeColor = Color.FromArgb(230, 126, 34);
}
private void button2_MouseMove(object sender, MouseEventArgs e)
{
button2.ForeColor = Color.FromArgb(100, 100, 100);
}
private void button4_MouseMove(object sender, MouseEventArgs e)
{
button2.ForeColor = Color.FromArgb(100, 100, 100);
}
private void button2_MouseDown(object sender, MouseEventArgs e)
{
button2.FlatAppearance.BorderColor = Color.DimGray;
button2.BackColor = Color.DimGray;
}
private void button4_MouseDown(object sender, MouseEventArgs e)
{
button2.FlatAppearance.BorderColor = Color.DimGray;
button2.BackColor = Color.DimGray;
}
private void button2_MouseUp(object sender, MouseEventArgs e)
{
button2.FlatAppearance.BorderColor = Color.FromArgb(230, 126, 34);
}
private void button4_MouseUp(object sender, MouseEventArgs e)
{
button2.FlatAppearance.BorderColor = Color.FromArgb(230, 126, 34);
}
private void button2_Click(object sender, EventArgs e)
{
this.Controls.Remove( button2 );
this.Controls.Remove( label1 );
this.Controls.Remove( textBox1 );
this.Controls.Remove( textBox2 );
this.Controls.Remove( label3 );
this.Controls.Remove( label4 );
// Form №2
label2.Text = "Вопрос первый!";
// Ответ 1
Button button4 = new Button();
button4.Text = "Вариант ответа 1";
button4.Size = new System.Drawing.Size(350, 50);
button4.Location = new Point(120, 370);
button4.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
button4.Font = new System.Drawing.Font("Verdana", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
button4.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(126)))), ((int)(((byte)(34)))));
button4.FlatAppearance.BorderSize = 3;
button4.UseVisualStyleBackColor = true;
button4.Name = "button4";
button4.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(126)))), ((int)(((byte)(34)))));
button4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(126)))), ((int)(((byte)(34)))));
button4.MouseLeave += new System.EventHandler(this.button4_MouseLeave);
button4.MouseDown += new System.Windows.Forms.MouseEventHandler(this.button4_MouseDown);
button4.MouseMove += new System.Windows.Forms.MouseEventHandler(this.button4_MouseMove);
button4.MouseUp += new System.Windows.Forms.MouseEventHandler(this.button4_MouseUp); this.Controls.Add(button4);
// Ответ 2
Button button5 = new Button();
button5.Text = "Вариант ответа 2";
button5.Size = button4.Size;
button5.Location = new Point(button4.Location.X + button4.Width + 20, 370);
button5.FlatStyle = button4.FlatStyle;
button5.Font = button4.Font;
button5.FlatAppearance.BorderColor = button4.FlatAppearance.BorderColor;
button5.FlatAppearance.BorderSize = button4.FlatAppearance.BorderSize;
button5.UseVisualStyleBackColor = button4.UseVisualStyleBackColor;
button5.FlatAppearance.MouseOverBackColor = button4.FlatAppearance.MouseOverBackColor;
button5.ForeColor = button4.ForeColor;
this.Controls.Add(button5);
// Ответ 3
Button button6 = new Button();
button6.Text = "Вариант ответа 3";
button6.Size = button4.Size;
button6.Location = new Point(120, button4.Location.Y + button4.Height + 20);
button6.FlatStyle = button4.FlatStyle;
button6.Font = button4.Font;
button6.FlatAppearance.BorderColor = button4.FlatAppearance.BorderColor;
button6.FlatAppearance.BorderSize = button4.FlatAppearance.BorderSize;
button6.UseVisualStyleBackColor = button4.UseVisualStyleBackColor;
button6.FlatAppearance.MouseOverBackColor = button4.FlatAppearance.MouseOverBackColor;
button6.ForeColor = button4.ForeColor;
this.Controls.Add(button6);
// Ответ 4
Button button7 = new Button();
button7.Text = "Вариант ответа 4";
button7.Size = button4.Size;
button7.Location = new Point(button5.Location.X, button6.Location.Y);
button7.FlatStyle = button4.FlatStyle;
button7.Font = button4.Font;
button7.FlatAppearance.BorderColor = button4.FlatAppearance.BorderColor;
button7.FlatAppearance.BorderSize = button4.FlatAppearance.BorderSize;
button7.UseVisualStyleBackColor = button4.UseVisualStyleBackColor;
button7.FlatAppearance.MouseOverBackColor = button4.FlatAppearance.MouseOverBackColor;
button7.ForeColor = button4.ForeColor;
this.Controls.Add(button7);
}
}
}