473,734 Members | 2,806 Online
Bytes | Software Development & Data Engineering Community
+ 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.Clo sing() denotes a 'method' which is
not valid in the given context" error.
Nov 17 '05 #1
6 5663
Hi,

Check the following:

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

this.Closing += new
System.Componen tModel.CancelEv entHandler(this .Form1_Closing) ;

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

private void Form1_Closing(o bject sender,
System.Componen tModel.CancelEv entArgs 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.Clo sing() 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.m icrosoft.com> wrote in
message news:2A******** *************** ***********@mic rosoft.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.Clo sing() 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_Closin g(object sender,
System.Componen tModel.CancelEv entArgs 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.m icrosoft.com> wrote in
message news:2A******** *************** ***********@mic rosoft.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.Clo sing() 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 InitializeCompo nent():
this.Closing += new System.Componen tModel.CancelEv entHandler(this .Closing);

Visual Studio added the following function:
private void Closing(object sender, System.Componen tModel.CancelEv entArgs e)

When I try to build I get the following error on the line that was added to
InitializeCompo nent(). 'Test.Form1.Clo sing(object,
System.Componen tModel.CancelEv entArgs)' 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.Clo sing() 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*********@yah oo.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 InitializeCompo nent():
this.Closing += new System.Componen tModel.CancelEv entHandler(this .Closing);

Visual Studio added the following function:
private void Closing(object sender, System.Componen tModel.CancelEv entArgs e)

When I try to build I get the following error on the line that was added to
InitializeCompo nent(). 'Test.Form1.Clo sing(object,
System.Componen tModel.CancelEv entArgs)' 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.Clo sing() 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 InitializeCompo nent():
this.Closing += new System.Componen tModel.CancelEv entHandler(this .Closing);

Visual Studio added the following function:
private void Closing(object sender, System.Componen tModel.CancelEv entArgs e)

When I try to build I get the following error on the line that was added to
InitializeCompo nent(). 'Test.Form1.Clo sing(object,
System.Componen tModel.CancelEv entArgs)' 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.Clo sing() 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
2259
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 is to ensure that no child window can close while it is in a state where user entered information can be lost. I have just noticed that while the Closing event is caught if I click the X on the child window, it is not caught if I click the X on...
1
5819
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 MDI child window. My application does certain logic when the user actually closes the MDI child form by clicking the "X" in the upper right hand. My application, however, should not execute this logic if the user closes the MDI parent. I...
1
2203
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
2252
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. this i am doing with Session_Onstart. 2) Now when user is exiting i.e. closing the browser window i want to trap this event and perform some operation. I tried using Session_OnEnd event,but
10
4025
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 application. What should happen, is that the main MDI form should close, taking the child forms with it. There is code to loop through the child forms, remove the controls on each of them, and then close the form, but this code should execute only...
2
3021
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 and then attempts to close the window (either via my custom 'Close' box or by clicking the close 'X' in the upper right window corner), the validation event still triggers and it tells the user that they have invalid data. Which of course means...
4
3007
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 another when its form Closing routine is run? I guess what I'm asking is will that work. If one form sets e.cancelled to true will e.cancel be true when the next form receives a closing event?
14
3365
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 I'll make the inactive forms invisible but this is creating a memory corruption problem when user close the form2 or form3 and not the formMain. My main form has a Next button which makes the main form invisible and starts a new form which I'll...
19
3226
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 these Validating Events are also fired when either the child form or the main (parent) form Close icon is clicked. And I need for these events to know if they are being invoked because the app (or child window) is being closed. I have set a boolean...
0
8946
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8776
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9310
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9236
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8186
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6031
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
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 we have to send another system
2
2724
muto222
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.