c# windows form event handling

Posted on 2006-04-16
Last Modified: 2010-04-16
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.
Question by:augie0216
    LVL 85

    Accepted Solution

    Double click the button in the IDE...

    private void button1_Click(object sender, System.EventArgs e)
        label1.Text = "something...";
    LVL 19

    Assisted Solution

    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";
    LVL 3

    Expert Comment

    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

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    In one of my recent projects, I was working with IP cameras, I need to take some pictures from the camera and do some processing on it. The first step, was to retrieve the image from camera into Image object. So that it can be displayed or …
    Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    This video discusses moving either the default database or any database to a new volume.

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now