add event handler?

Stained_Silva

New member
Joined
Jan 23, 2015
Messages
4
Programming Experience
Beginner
Hi there,

I have just started my course in C#, I am stuck on a question in my book. The book comes without answers and the question I have been asked, I have not covered on how to do as yet.

This is literally Question 6 on chapter 2 of The C# development environment.

It involves using the "MouseHover" event, they want me to create a method that handles this event.

They start by saying I need to place a button on a form( which I did ), then here I get lost ( "At the top of the text editor pane, select button1 and Mousehover"), I dont know where this text editor pane is or where I am supposed to select..
It goes on by saying once these have been selected a method to handle the event is created.

Then I have to write a program which displays a message box containing "Over Button" when the mouse is held over the button.

Below is as far as I've gotten, which is just a form with a button on it, please could you show me where I should be looking for button1 and MouseHover in order to start the method?

Many thanks.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
    }
}
 
Last edited by a moderator:
That's a bit weird. The advice they seem to be giving you would apply to VB but not C#. In VB there are two ways to generate event handlers but in C# there is only one. In either language, you can select the component in the designer for which you want to add the event handler, open the Properties window, click the Events button at the top and then double-click the event you want to handle. That's what you need to do.

What they describe only works in VB. The text editor they mention is the code window. In VB you can select a component in one of the drop-down lists at the top of the code window and then select an event in another drop-down to generate a handler for that event. C# has similar drop-downs but they only allow you to navigate to existing members, not generate new ones.
 
Back
Top Bottom