2 кнопки генерируют одну функцию C#
Есть 2 кнопки на форме, нажимаю 2 раза на одну из них что бы та в свой черед сгенерировала функцию обработки нажатия. Таким же образом поступаю и со 2-й кнопкой и меня перекидывает на функцию созданную 1-й кнопкой. Что делать? Удаление, на моё удивление не помогает.
Code of Form:
namespace WindowsFormsApp2
{
partial class main_form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.btnClose = new System.Windows.Forms.Button();
this.panel2 = new System.Windows.Forms.Panel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.panelNews = new System.Windows.Forms.Panel();
this.labelNews = new System.Windows.Forms.Label();
this.btnMinimize = new System.Windows.Forms.Button();
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.panelNews.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(61)))), ((int)(((byte)(138)))), ((int)(((byte)(190)))));
this.panel1.Controls.Add(this.btnMinimize);
this.panel1.Controls.Add(this.btnClose);
this.panel1.Controls.Add(this.panel2);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(926, 35);
this.panel1.TabIndex = 0;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// btnClose
//
this.btnClose.FlatAppearance.BorderSize = 0;
this.btnClose.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnClose.Font = new System.Drawing.Font("Arial Rounded MT Bold", 14F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnClose.ForeColor = System.Drawing.Color.Cornsilk;
this.btnClose.Location = new System.Drawing.Point(819, 0);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(75, 35);
this.btnClose.TabIndex = 0;
this.btnClose.Text = "X";
this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// panel2
//
this.panel2.Controls.Add(this.pictureBox1);
this.panel2.Dock = System.Windows.Forms.DockStyle.Left;
this.panel2.Location = new System.Drawing.Point(0, 0);
this.panel2.Margin = new System.Windows.Forms.Padding(5);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(80, 35);
this.panel2.TabIndex = 0;
this.panel2.Paint += new System.Windows.Forms.PaintEventHandler(this.panel2_Paint);
//
// pictureBox1
//
this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Right;
this.pictureBox1.Image = global::WindowsFormsApp2.Properties.Resources.icons8_full_moon_96;
this.pictureBox1.Location = new System.Drawing.Point(30, 0);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Padding = new System.Windows.Forms.Padding(5);
this.pictureBox1.Size = new System.Drawing.Size(50, 35);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// panelNews
//
this.panelNews.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(61)))), ((int)(((byte)(138)))), ((int)(((byte)(190)))));
this.panelNews.Controls.Add(this.labelNews);
this.panelNews.Location = new System.Drawing.Point(55, 68);
this.panelNews.Name = "panelNews";
this.panelNews.Size = new System.Drawing.Size(364, 433);
this.panelNews.TabIndex = 1;
//
// labelNews
//
this.labelNews.AutoSize = true;
this.labelNews.Font = new System.Drawing.Font("SFNS Display", 27.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(220)));
this.labelNews.ForeColor = System.Drawing.Color.Snow;
this.labelNews.Location = new System.Drawing.Point(81, 26);
this.labelNews.Name = "labelNews";
this.labelNews.Size = new System.Drawing.Size(203, 44);
this.labelNews.TabIndex = 0;
this.labelNews.Text = "НОВОСТИ";
//
// btnMinimize
//
this.btnMinimize.FlatAppearance.BorderSize = 0;
this.btnMinimize.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnMinimize.Font = new System.Drawing.Font("Arial Rounded MT Bold", 14F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnMinimize.ForeColor = System.Drawing.Color.Cornsilk;
this.btnMinimize.Location = new System.Drawing.Point(738, -3);
this.btnMinimize.Name = "btnMinimize";
this.btnMinimize.Size = new System.Drawing.Size(75, 35);
this.btnMinimize.TabIndex = 0;
this.btnMinimize.Text = "X";
this.btnMinimize.UseVisualStyleBackColor = true;
this.btnMinimize.Click += new System.EventHandler(this.btnClose_Click);
//
// main_form
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(83)))), ((int)(((byte)(179)))), ((int)(((byte)(230)))));
this.ClientSize = new System.Drawing.Size(926, 563);
this.Controls.Add(this.panelNews);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "main_form";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "mainform";
this.Load += new System.EventHandler(this.main_form_Load);
this.panel1.ResumeLayout(false);
this.panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.panelNews.ResumeLayout(false);
this.panelNews.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.Panel panelNews;
private System.Windows.Forms.Label labelNews;
private System.Windows.Forms.Button btnMinimize;
}
}
Ответы (1 шт):
Автор решения: Igor
→ Ссылка
Удалите эту строчку
this.btnMinimize.Click += new System.EventHandler(this.btnClose_Click);
Вы, вероятно, создали btnMinimize скопировав btnClose.