• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 250
  • Last Modified:

c# windows form event handling

I'm having a problem coding a windows form using Visual Studio IDE the book I'm using is about as clear as mud. How do you code a button so it triggers an event in a label? I know this question is vague, but just need a hint if i'm still confused i'll ask other questions.
0
augie0216
Asked:
augie0216
2 Solutions
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Double click the button in the IDE...

private void button1_Click(object sender, System.EventArgs e)
{
    label1.Text = "something...";
}
0
 
Fahad MukhtarDistinguished EngineerCommented:
following code raises the label click event from button click event

     private void button1_Click(object sender, EventArgs e)
        {
            label1_Click(button1, e);
        }

        private void label1_Click(object sender, EventArgs e)
        {
            if (sender is Button) // if the button is clicked
            label1.Text = "Lable Click Event Fired(from button)";
            else //if the label itself clicked
            label1.Text = "Lable Click Event Fired";
        }
0
 
maidinhtaiCommented:
First, select the control -> In the properties windows, select events icon (a lightning shape) -> double click the event you want (you can enter a name or use the default name of the event) -> Write handing code
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now