473,480 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to add an event handler to a form in VS 2005?

Hello,
I would like to add the Paint handler to the form. How to do it?
Thanks in advance.
Sep 28 '08 #1
2 1809
On Sun, 28 Sep 2008 16:43:00 -0700, RRJ <RR*@discussions.microsoft.com>
wrote:
Hello,
I would like to add the Paint handler to the form. How to do it?
What do you mean? Do you mean you have an event handler that you want
subscribed to a form's Paint event? Or do you mean you have a form's
Paint event and you want to write an event handler for it?

In either case, there are ways to do it using the IDE and doing it
manually.

Subscribe an event handler:

-- Using the IDE, choose the "Events" list in the form's Properties
window, find the Paint event, click in the edit area and a drop-down
showing all eligible handlers in the container will be shown (in this
case, that's likely to just be the form)

-- Doing it manually, simply use the C# event add syntax. For
example, where the handler method's name is "MyPaintHandler":

Form form = ...; // your initialization goes here

form.Paint += MyPaintHandler;

Write an event handler:

-- Using the IDE, as above for subscribing a handler, but double-click
in the edit area instead. A new handler will be inserted in the relevant
container class, to which you can add whatever code you want.

-- Doing it manually, just write the event handler method, ensuring
that the signature for the method is correct. For the Paint event, you
need a method that looks like this:

void MyPaintHandler(object sender, PaintEventArgs e)
{
}

Pete
Sep 29 '08 #2
Thanks Pete.

I could add the event manually, but didn't know how to do it from IDE. Your
solution (properties->events) helped solve it.

Thanks again.

"Peter Duniho" wrote:
On Sun, 28 Sep 2008 16:43:00 -0700, RRJ <RR*@discussions.microsoft.com>
wrote:
Hello,
I would like to add the Paint handler to the form. How to do it?

What do you mean? Do you mean you have an event handler that you want
subscribed to a form's Paint event? Or do you mean you have a form's
Paint event and you want to write an event handler for it?

In either case, there are ways to do it using the IDE and doing it
manually.

Subscribe an event handler:

-- Using the IDE, choose the "Events" list in the form's Properties
window, find the Paint event, click in the edit area and a drop-down
showing all eligible handlers in the container will be shown (in this
case, that's likely to just be the form)

-- Doing it manually, simply use the C# event add syntax. For
example, where the handler method's name is "MyPaintHandler":

Form form = ...; // your initialization goes here

form.Paint += MyPaintHandler;

Write an event handler:

-- Using the IDE, as above for subscribing a handler, but double-click
in the edit area instead. A new handler will be inserted in the relevant
container class, to which you can add whatever code you want.

-- Doing it manually, just write the event handler method, ensuring
that the signature for the method is correct. For the Paint event, you
need a method that looks like this:

void MyPaintHandler(object sender, PaintEventArgs e)
{
}

Pete
Sep 29 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
2848
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code...
6
2185
by: Shimon Sim | last post by:
I have Panel control on the page. I am handling Init event for it. It doesn't seem to fire at all. Why? Thank you Shimon.
1
3292
by: fripper | last post by:
I have a VB 2005 windows app and I want to recognize keydown events. I have a form key down event handler but it does not get control when a key is depressed. In playing around I found that if I...
6
8753
by: Joseph Geretz | last post by:
I'm porting a C# Outlook Addin originally engineered as a COM Addin over to use VSTO. I've gotten this to the point where my VSTO Addin installs its Menu items and Toolbar buttons when Outlook...
6
8651
by: Rob Peterson | last post by:
Hi there, Does anyone know how to actually "abort" the event (component change) described in the following link. Apparently it's doable as mentined in the "Remarks" section but how....
2
3894
by: John Kotuby | last post by:
Hi guys, I am converting a rather complicated database driven Web application from classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The original ASP application works quite...
2
1559
by: hharry | last post by:
Hello All, In VS 2003, I was able to add event handlers in the InitializeComponent function. In VS 2005, I can no longer see the auto- generated code. I tried to add the event handler for a...
0
4586
by: =?Utf-8?B?YW5rMmdv?= | last post by:
Hi, Thanks in advance for reading this. Not sure where to post this question, but I hope someone in here can help. Trying to write to Event Log in VS 2005 (.NET 2.0) using Enterprise Library...
1
10884
by: JDeats | last post by:
If you create a new C# Windows Application project in Visual Studio.NET 2003 or 2005 and proceed to. 1. Make default form size 800x600 2. Drop a CheckBoxList control and dock it to the left 3....
0
7054
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7102
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5357
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4798
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3008
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3000
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1310
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
570
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.