473,473 Members | 2,232 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Closing event

I want to catch the Closing event for my form. I created a test windows app
using the wizard. I then create the Closing event by clicking the lightning
bolt on the properties pane. The code is added to the app but my app won't
compile. It generates a "Test.Form1.Closing() denotes a 'method' which is
not valid in the given context" error.
Nov 17 '05 #1
6 5641
Hi,

Check the following:

1) Check that you have a line on the Windows designer code like:

this.Closing += new
System.ComponentModel.CancelEventHandler(this.Form 1_Closing);

2) Note if the function "Form1_Closing" (the form1 will be the name of your
form) exists like

private void Form1_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
//Put your stuff here
}

I use to mess around with my events and remove the function when the
overloading is still there!. The wizard that creates the event can not handle
changes on its code :)

Salva
Hi,

Upon a string class lenght is set to UInt32, actually is not real, it has a
much limited number, I found a very interesting page about strings.

http://www.codeproject.com/dotnet/strings.asp

Anyway, back to your case, it seems that the message box has a limit on the
amount of data that can show, this seems to be normal, otherwise imaging a
hugh message box with 2Mb of string data!

Best regards
Salva
"Al the programmer" wrote:
I want to catch the Closing event for my form. I created a test windows app
using the wizard. I then create the Closing event by clicking the lightning
bolt on the properties pane. The code is added to the app but my app won't
compile. It generates a "Test.Form1.Closing() denotes a 'method' which is
not valid in the given context" error.

Nov 17 '05 #2
hi,

can you post the code in question, double click the closing event and this
will create the method you need and the hook needed.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Al the programmer" <Al*************@discussions.microsoft.com> wrote in
message news:2A**********************************@microsof t.com...
I want to catch the Closing event for my form. I created a test windows
app
using the wizard. I then create the Closing event by clicking the
lightning
bolt on the properties pane. The code is added to the app but my app
won't
compile. It generates a "Test.Form1.Closing() denotes a 'method' which is
not valid in the given context" error.

Nov 17 '05 #3
Hi there,
the correct way of the event closing is:
private void TestForm_Closing(object sender,
System.ComponentModel.CancelEventArgs e)

{
}

in your post you don't have any arguments, so if the generator of VS have
some problem then copy and pasty the above function, and then go to the
events property window and intead of double-clicking the closing event just
dropDown the list and you will be able to assing the above function to the
event.

hope that helps

"Al the programmer" <Al*************@discussions.microsoft.com> wrote in
message news:2A**********************************@microsof t.com...
I want to catch the Closing event for my form. I created a test windows
app
using the wizard. I then create the Closing event by clicking the
lightning
bolt on the properties pane. The code is added to the app but my app
won't
compile. It generates a "Test.Form1.Closing() denotes a 'method' which is
not valid in the given context" error.

Nov 17 '05 #4
It appears Visual Studio is doing something wrong. All I am doing is
creating a Windows application and then adding a "Closing" event.

Visual Studio added the following code to InitializeComponent():
this.Closing += new System.ComponentModel.CancelEventHandler(this.Clos ing);

Visual Studio added the following function:
private void Closing(object sender, System.ComponentModel.CancelEventArgs e)

When I try to build I get the following error on the line that was added to
InitializeComponent(). 'Test.Form1.Closing(object,
System.ComponentModel.CancelEventArgs)' denotes a 'method' which is not valid
in the given context
"Al the programmer" wrote:
I want to catch the Closing event for my form. I created a test windows app
using the wizard. I then create the Closing event by clicking the lightning
bolt on the properties pane. The code is added to the app but my app won't
compile. It generates a "Test.Form1.Closing() denotes a 'method' which is
not valid in the given context" error.

Nov 17 '05 #5
Hi,

Can you send me that sample app to sa*********@yahoo.co.uk, I will have a
look and give you an answer

"Al the programmer" wrote:
It appears Visual Studio is doing something wrong. All I am doing is
creating a Windows application and then adding a "Closing" event.

Visual Studio added the following code to InitializeComponent():
this.Closing += new System.ComponentModel.CancelEventHandler(this.Clos ing);

Visual Studio added the following function:
private void Closing(object sender, System.ComponentModel.CancelEventArgs e)

When I try to build I get the following error on the line that was added to
InitializeComponent(). 'Test.Form1.Closing(object,
System.ComponentModel.CancelEventArgs)' denotes a 'method' which is not valid
in the given context
"Al the programmer" wrote:
I want to catch the Closing event for my form. I created a test windows app
using the wizard. I then create the Closing event by clicking the lightning
bolt on the properties pane. The code is added to the app but my app won't
compile. It generates a "Test.Form1.Closing() denotes a 'method' which is
not valid in the given context" error.

Nov 17 '05 #6
Hi,

You were calling the event handler function "Closing" and it was clashing
with the "Closing" delegate of the form. Changing the name solves the problem.

Regards
Salva
"Al the programmer" wrote:
It appears Visual Studio is doing something wrong. All I am doing is
creating a Windows application and then adding a "Closing" event.

Visual Studio added the following code to InitializeComponent():
this.Closing += new System.ComponentModel.CancelEventHandler(this.Clos ing);

Visual Studio added the following function:
private void Closing(object sender, System.ComponentModel.CancelEventArgs e)

When I try to build I get the following error on the line that was added to
InitializeComponent(). 'Test.Form1.Closing(object,
System.ComponentModel.CancelEventArgs)' denotes a 'method' which is not valid
in the given context
"Al the programmer" wrote:
I want to catch the Closing event for my form. I created a test windows app
using the wizard. I then create the Closing event by clicking the lightning
bolt on the properties pane. The code is added to the app but my app won't
compile. It generates a "Test.Form1.Closing() denotes a 'method' which is
not valid in the given context" error.

Nov 17 '05 #7

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

Similar topics

5
by: Ron L | last post by:
I have an MDI application with a number of child windows. In each child window I am catching the Closing event and having the child window decide if it should set cancel to true. The intent here...
1
by: Chris Bruce | last post by:
In my application I need a way to distiguish between the following events: 1. When a user closes an MDI child window. 2. When the user closes the MDI parent window which subsequently closes the...
1
by: **Developer** | last post by:
When I get a closing event in a MID Child form I don't know if the child form is closing or the main form is closing. Is there a way to tell? Thank
1
by: Chirag Malvi | last post by:
hello all, I am developing the web application using ASP.net and VS.2003 IDE. here is the situation which i want to implement. 1) User is browsing some webform. I want to trap this event....
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
2
by: Tom | last post by:
How is the best way to avoid validation when closing a window? For instance, I have a Windows Forms window which has a validation event for a text box. However, if one enters invalid data in then...
4
by: Academic | last post by:
Does it make sense to put this If e.Cancel Then Exit Sub at the beginning of form closing events so if the user cancels the app's exiting in one Closing routine he will not be asked again by...
14
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using VS2005 and .net 2.0. I'm creating an application that has 3 forms. I want allow users to move forward and backward with the forms and retain the data users have entered. I thought...
19
by: zacks | last post by:
I have a .NET 2.0 MDI application where the child form has a Tab Control. Each of the Tab in the Tab Control has a Validating event to handle what it should do when the user changes tabs. But...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
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.