Click here to Skip to main content
15,919,479 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi folks, I am creating some controls at runtime and when the user clicks that control, I want to use MsgBox to display the control's caption.
Posted
Updated 31-Oct-10 3:40am
v2

Handle the Click event, the sender argument passed to the event handler will be the source control. Use MsgBox to display the Text property of that Control.
 
Share this answer
 
v2
Comments
sameertm 31-Oct-10 9:48am    
i don no hw to do this pls give me some example code for this
Dalek Dave 31-Oct-10 10:06am    
Good answer.
Hi, here is one solution (in C#) for a button click event handler. Just use the click event handler of your own control.
C#
private void btn_click(object sender, EventArgs e)
{
  Button button = sender as Button;
  if(button != null)
  {
    MessageBox.Show(button.Text);
  }
}
 
Share this answer
 
v2
Comments
Dalek Dave 31-Oct-10 10:06am    
Good call.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900