koba Tirth

koba Tirth

  • NA
  • 50
  • 21.1k

C#.net winform : How to access form event in user control ??

May 5 2017 6:55 AM
 
I have created one winform, Load user controle on that form and adding text box run time in that controle. I have created one event to handle text_change of that text box, but can not access that event, because event was created on winform and contrle can not access it.
How can fix this issue, Kindly help in this regard.
Code is given below for ready refereence.
Thanks
 
Form :
public class form1:Form
{
public form1()
{
InitializeComponent();
}
usercon uscon=new usercon();
private void form1_Load (object sender, EventArgs e)
{
uscon.Parent=panel1;
}
private void txt_textchange(object sender, EventArgs e)
{}
}
 
User control :
public class usercon : UserControl
{
public usercon()
{
InitializeComponent();
}
private void btn_multi_Click(object sender, EventArgs e)
{
TextBox txtbox = new TextBox();
txtbox.Name = dynamictxt";
txtbox.Location = new Point(59, 30);
txtbox.Size = new System.Drawing.Size(188, 20);
Panel1.Controls.Add(txtbox);
}
}

Answers (11)