Actually I created user control and successfully added with tools option but when this control use in another form. So write some code then
below code are fired
private void userControl11_Load(object sender, EventArgs e)
{
label1.Text = "UserControl loaded";
// Button1
//
this.Button1.Location = new System.Drawing.Point(0, 0);
this.Button1.Name = "Button1";
this.Button1.Size = new System.Drawing.Size(75, 23);
this.Button1.TabIndex = 0;
<b>this.Button1.Click += new System.EventHandler(this.Button1_Click);
</b> //
but
public void Button1_Click(object sender, EventArgs e)
{
label1.Text = "Clicked by buttto1";
}
when using next code is not fire why >
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace test_CreatePannel
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private System.Windows.Forms.Button Button1;
private System.Windows.Forms.Button Button2;
private System.Windows.Forms.Button Button3;
private void userControl11_Load(object sender, EventArgs e)
{
label1.Text = "UserControl loaded";
// Button1
//
this.Button1.Location = new System.Drawing.Point(0, 0);
this.Button1.Name = "Button1";
this.Button1.Size = new System.Drawing.Size(75, 23);
this.Button1.TabIndex = 0;
this.Button1.Click += new System.EventHandler(this.Button1_Click);
//
}
public void Button1_Click(object sender, EventArgs e)
{
label1.Text = "Clicked by buttto1";
}
private void btnAdd_Click(object sender, EventArgs e)
{
label1.Text = "Clicked by buttton Add";
}
}
}