I should not create and use the button in my
appln.If i click anywhere in the User control ,it ll do something.The
user control contains 4 labels only... Now plz tell me is any other way
(without button creation) to do this task??
So, if I understand you, you want to respond to the "Click" event of
the UserControl itself.
If that's so, Seraph just showed you how to do it for a dynamically
created button. Just do exactly the same thing, substituting your
UserControl for Seraph's Button.
If I misunderstand, then maybe you could post the code to your
UserControl and explain in more detail what it is you want to do.
Well, just do exactly what Seraph showed you, but with your
UserControl:
MyUserControl user = new MyUserControl();
user.ID="user";
this.Controls.Add(user);
user.Click += new System.EventHandler(this.user_Click);
and then, somewhere in your code:
private void user_Click(object sender, System.EventArgs e)
{
... do whatever you want when the butotn is clicked ...
}
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.