Closing event

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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,
 
Hi,

Check the following:

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

this.Closing += new
System.ComponentModel.CancelEventHandler(this.Form1_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
 
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
 
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.Closing);

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
 
Hi,

Can you send me that sample app to (e-mail address removed), I will have a
look and give you an answer
 
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
 
Back
Top