Cancel Form Closing

Sorry about the delay in getting you an answer, I've been a little busy the last few years. Epicor hides the form before you get the FormClosing event. You just need to re-show the form. The following snippet should do the trick:


args.Cancel = true
UD101Form.Show()



On Mon, Sep 19, 2011 at 8:53 AM, sanfordm99 <sanfordm99@…> wrote:

Â
<div>
  
  
  <p><br>

Thanks everyone for the replies. Here is some sample code that I have tried. This compiles fine, but does not work. The form still closes. I am using Version 8.03.408B.

Private Sub UD101Form_Closing(ByVal sender As object, ByVal args As System.ComponentModel.CancelEventArgs) Handles UD101Form.Closing
'//
'// Add Event Handler Code
'//
args.Cancel = true
End Sub

The goal of this is for validation. Basically, after a message box, I want the user to have the option to not close the form. Anyone have any ideas?

Thanks,
Mike



--- In vantage@yahoogroups.com, Waffqle <waffqle@...> wrote:
>
> e.Cancel works for me as well.
>
> On Thu, Sep 15, 2011 at 8:55 AM, sanfordm99 <sanfordm99@...> wrote:
>
> > **

> >
> >
> > Thanks for the reply. I should have mentioned that I am on version 8 and
> > trying to do this for UD101. It is also VB (which shouldn't matter).
> >
> > Thanks,
> > Mike
> >
> >
> > --- In vantage@yahoogroups.com, Jose Gomez <jose@> wrote:
> > >
> > > This works fine for me
> > > private void QuoteEntryForm_FormClosing(object sender,
> > FormClosingEventArgs
> > > e)
> > > {
> > > e.Cancel = true;
> > > }
> > >
> > > *Jose C Gomez*
> > > *Software Engineer*
> > > *
> > > *
> > > *checkout my new blog <http://www.usdoingstuff.com> *
> > > *
> > > *T: 904.469.1524 mobile
> > > E: jose@
> >
> > > On Thu, Sep 15, 2011 at 8:38 AM, sanfordm99 <sanfordm99@> wrote:
> > >
> > > > **
> > > >
> > > >
> > > > Hello,
> > > >
> > > > Has anyone figured this one out? The CancelEventHandler suggested here
> > is
> > > > not a boolean, it is a handler (ie to the closing event). So, it should
> > be
> > > > the args.Cancel = true (which is a property of the handler). This
> > doesn't
> > > > work for me either. Any ideas?
> > > >
> > > > Thanks,
> > > > Mike
> > > >
> > > >
> > > > --- In vantage@yahoogroups.com, Kunal Ganguly <kunal_vantage@> wrote:
> > > > >
> > > > > The second links says that you need to set the CancelEventHandler to
> > true
> > > > >
> > > > > so... in pseudocode
> > > > >
> > > > > private form_closing() handles form.closing
> > > > > [form.]CancelEventHandler = true
> > > > > end sub
> > > > >
> > > > >
> > > > > unless you call calling this sub somewhere else, you really don't
> > need to
> > > > do anything with the args variable.
> > > > >
> > > > > Thanks,
> > > > > Kunal
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > ________________________________
> > > > > From: drew.pete <drew.pete@>
> > > >
> > > > > To: vantage@yahoogroups.com
> > > > > Sent: Tue, January 5, 2010 2:35:07 PM
> > > > > Subject: [Vantage] Re: Cancel Form Closing
> > > > >
> > > > >
> > > > > Kunal,
> > > > >
> > > > > Thanks for the links. After comparing both links I couldn't see why
> > the
> > > > following code I have wouldn't work...
> > > > >
> > > > > Private Sub JobEntryForm_ Closing(ByVal sender As object, ByVal args
> > As
> > > > System.ComponentMod el.CancelEventAr gs) Handles JobEntryForm. Closing
> > > > >
> > > > > args.Cancel = true
> > > > >
> > > > > End sub
> > > > >
> > > > > It doesn't error out at all for me - it just doesn't cancel the
> > closing
> > > > of the form.
> > > > >
> > > > > Thanks,
> > > > > Drew
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > [Non-text portions of this message have been removed]
> > > > >
> > > >
> > > >
> > > >
> > >
> > >
> > > [Non-text portions of this message have been removed]
> > >
> >
> >
> >
>
>
>
> --
> *Waffqle Driggers*
> *High End Dev, System Design, Profit Drinking
> *
> *:: 904.962.2887*
> *:: waffqle@...*
> *:: NO FAXES*
>
> *

>
> *
>
>
> [Non-text portions of this message have been removed]
>

</div>
 


<div style="color:#fff;min-height:0;"></div>

Is there a way to cancel the closing of a form? I tried args.cancel = true on the form event "closing" but that didn't work. Any ideas?

Thanks

Drew
This is a good explanation of what happens:
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.formclosing.aspx

and this is how to interrupt it, you will have to figure out the equivalent vb.net code

http://www.dotnetmonster.com/Uwe/Forum.aspx/winform/1885/overriding-form-close-button
quote - "You can prevent a form from closing by handling its Closing event and
setting the CancelEventHandler to true."

Thanks,
Kunal




________________________________
From: drew.pete <drew.pete@...>
To: vantage@yahoogroups.com
Sent: Tue, January 5, 2010 8:39:14 AM
Subject: [Vantage] Cancel Form Closing


Is there a way to cancel the closing of a form? I tried args.cancel = true on the form event "closing" but that didn't work. Any ideas?

Thanks

Drew







[Non-text portions of this message have been removed]
Kunal,

Thanks for the links. After comparing both links I couldn't see why the following code I have wouldn't work...

Private Sub JobEntryForm_Closing(ByVal sender As object, ByVal args As System.ComponentModel.CancelEventArgs) Handles JobEntryForm.Closing

args.Cancel = true

End sub

It doesn't error out at all for me - it just doesn't cancel the closing of the form.

Thanks,
Drew
The second links says that you need to set the CancelEventHandler to true

so... in pseudocode

private form_closing() handles form.closing
[form.]CancelEventHandler = true
end sub


unless you call calling this sub somewhere else, you really don't need to do anything with the args variable.

Thanks,
Kunal




________________________________
From: drew.pete <drew.pete@...>
To: vantage@yahoogroups.com
Sent: Tue, January 5, 2010 2:35:07 PM
Subject: [Vantage] Re: Cancel Form Closing


Kunal,

Thanks for the links. After comparing both links I couldn't see why the following code I have wouldn't work...

Private Sub JobEntryForm_ Closing(ByVal sender As object, ByVal args As System.ComponentMod el.CancelEventAr gs) Handles JobEntryForm. Closing

args.Cancel = true

End sub

It doesn't error out at all for me - it just doesn't cancel the closing of the form.

Thanks,
Drew







[Non-text portions of this message have been removed]
Hello,

Has anyone figured this one out? The CancelEventHandler suggested here is not a boolean, it is a handler (ie to the closing event). So, it should be the args.Cancel = true (which is a property of the handler). This doesn't work for me either. Any ideas?


Thanks,
Mike


--- In vantage@yahoogroups.com, Kunal Ganguly <kunal_vantage@...> wrote:
>
> The second links says that you need to set the CancelEventHandler to true
>
> so... in pseudocode
>
> private form_closing() handles form.closing
> [form.]CancelEventHandler = true
> end sub
>
>
> unless you call calling this sub somewhere else, you really don't need to do anything with the args variable.
>
> Thanks,
> Kunal
>
>
>
>
> ________________________________
> From: drew.pete <drew.pete@...>
> To: vantage@yahoogroups.com
> Sent: Tue, January 5, 2010 2:35:07 PM
> Subject: [Vantage] Re: Cancel Form Closing
>
>
> Kunal,
>
> Thanks for the links. After comparing both links I couldn't see why the following code I have wouldn't work...
>
> Private Sub JobEntryForm_ Closing(ByVal sender As object, ByVal args As System.ComponentMod el.CancelEventAr gs) Handles JobEntryForm. Closing
>
> args.Cancel = true
>
> End sub
>
> It doesn't error out at all for me - it just doesn't cancel the closing of the form.
>
> Thanks,
> Drew
>
>
>
>
>
>
>
> [Non-text portions of this message have been removed]
>
This works fine for me
private void QuoteEntryForm_FormClosing(object sender, FormClosingEventArgs
e)
{
e.Cancel = true;
}

*Jose C Gomez*
*Software Engineer*
*
*
*checkout my new blog <http://www.usdoingstuff.com> *
*
*T: 904.469.1524 mobile
E: jose@...
http://www.josecgomez.com
<http://www.linkedin.com/in/josecgomez> <http://www.facebook.com/josegomez>
<http://www.google.com/profiles/jose.gomez> <http://www.twitter.com/joc85>
<http://www.josecgomez.com/professional-resume/>
<http://www.josecgomez.com/feed/>
<http://www.usdoingstuff.com>

*Quis custodiet ipsos custodes?*



On Thu, Sep 15, 2011 at 8:38 AM, sanfordm99 <sanfordm99@...> wrote:

> **
>
>
> Hello,
>
> Has anyone figured this one out? The CancelEventHandler suggested here is
> not a boolean, it is a handler (ie to the closing event). So, it should be
> the args.Cancel = true (which is a property of the handler). This doesn't
> work for me either. Any ideas?
>
> Thanks,
> Mike
>
>
> --- In vantage@yahoogroups.com, Kunal Ganguly <kunal_vantage@...> wrote:
> >
> > The second links says that you need to set the CancelEventHandler to true
> >
> > so... in pseudocode
> >
> > private form_closing() handles form.closing
> > [form.]CancelEventHandler = true
> > end sub
> >
> >
> > unless you call calling this sub somewhere else, you really don't need to
> do anything with the args variable.
> >
> > Thanks,
> > Kunal
> >
> >
> >
> >
> > ________________________________
> > From: drew.pete <drew.pete@...>
>
> > To: vantage@yahoogroups.com
> > Sent: Tue, January 5, 2010 2:35:07 PM
> > Subject: [Vantage] Re: Cancel Form Closing
> >
> >
> > Kunal,
> >
> > Thanks for the links. After comparing both links I couldn't see why the
> following code I have wouldn't work...
> >
> > Private Sub JobEntryForm_ Closing(ByVal sender As object, ByVal args As
> System.ComponentMod el.CancelEventAr gs) Handles JobEntryForm. Closing
> >
> > args.Cancel = true
> >
> > End sub
> >
> > It doesn't error out at all for me - it just doesn't cancel the closing
> of the form.
> >
> > Thanks,
> > Drew
> >
> >
> >
> >
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
>
>
>


[Non-text portions of this message have been removed]
Thanks for the reply. I should have mentioned that I am on version 8 and trying to do this for UD101. It is also VB (which shouldn't matter).

Thanks,
Mike

--- In vantage@yahoogroups.com, Jose Gomez <jose@...> wrote:
>
> This works fine for me
> private void QuoteEntryForm_FormClosing(object sender, FormClosingEventArgs
> e)
> {
> e.Cancel = true;
> }
>
> *Jose C Gomez*
> *Software Engineer*
> *
> *
> *checkout my new blog <http://www.usdoingstuff.com> *
> *
> *T: 904.469.1524 mobile
> E: jose@...
> http://www.josecgomez.com
> <http://www.linkedin.com/in/josecgomez> <http://www.facebook.com/josegomez>
> <http://www.google.com/profiles/jose.gomez> <http://www.twitter.com/joc85>
> <http://www.josecgomez.com/professional-resume/>
> <http://www.josecgomez.com/feed/>
> <http://www.usdoingstuff.com>
>
> *Quis custodiet ipsos custodes?*
>
>
>
> On Thu, Sep 15, 2011 at 8:38 AM, sanfordm99 <sanfordm99@...> wrote:
>
> > **
> >
> >
> > Hello,
> >
> > Has anyone figured this one out? The CancelEventHandler suggested here is
> > not a boolean, it is a handler (ie to the closing event). So, it should be
> > the args.Cancel = true (which is a property of the handler). This doesn't
> > work for me either. Any ideas?
> >
> > Thanks,
> > Mike
> >
> >
> > --- In vantage@yahoogroups.com, Kunal Ganguly <kunal_vantage@> wrote:
> > >
> > > The second links says that you need to set the CancelEventHandler to true
> > >
> > > so... in pseudocode
> > >
> > > private form_closing() handles form.closing
> > > [form.]CancelEventHandler = true
> > > end sub
> > >
> > >
> > > unless you call calling this sub somewhere else, you really don't need to
> > do anything with the args variable.
> > >
> > > Thanks,
> > > Kunal
> > >
> > >
> > >
> > >
> > > ________________________________
> > > From: drew.pete <drew.pete@>
> >
> > > To: vantage@yahoogroups.com
> > > Sent: Tue, January 5, 2010 2:35:07 PM
> > > Subject: [Vantage] Re: Cancel Form Closing
> > >
> > >
> > > Kunal,
> > >
> > > Thanks for the links. After comparing both links I couldn't see why the
> > following code I have wouldn't work...
> > >
> > > Private Sub JobEntryForm_ Closing(ByVal sender As object, ByVal args As
> > System.ComponentMod el.CancelEventAr gs) Handles JobEntryForm. Closing
> > >
> > > args.Cancel = true
> > >
> > > End sub
> > >
> > > It doesn't error out at all for me - it just doesn't cancel the closing
> > of the form.
> > >
> > > Thanks,
> > > Drew
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > [Non-text portions of this message have been removed]
> > >
> >
> >
> >
>
>
> [Non-text portions of this message have been removed]
>
e.Cancel works for me as well.

On Thu, Sep 15, 2011 at 8:55 AM, sanfordm99 <sanfordm99@...> wrote:

> **
>
>
> Thanks for the reply. I should have mentioned that I am on version 8 and
> trying to do this for UD101. It is also VB (which shouldn't matter).
>
> Thanks,
> Mike
>
>
> --- In vantage@yahoogroups.com, Jose Gomez <jose@...> wrote:
> >
> > This works fine for me
> > private void QuoteEntryForm_FormClosing(object sender,
> FormClosingEventArgs
> > e)
> > {
> > e.Cancel = true;
> > }
> >
> > *Jose C Gomez*
> > *Software Engineer*
> > *
> > *
> > *checkout my new blog <http://www.usdoingstuff.com> *
> > *
> > *T: 904.469.1524 mobile
> > E: jose@...
>
> > http://www.josecgomez.com
> > <http://www.linkedin.com/in/josecgomez> <
> http://www.facebook.com/josegomez>
> > <http://www.google.com/profiles/jose.gomez> <
> http://www.twitter.com/joc85>
> > <http://www.josecgomez.com/professional-resume/>
> > <http://www.josecgomez.com/feed/>
> > <http://www.usdoingstuff.com>
> >
> > *Quis custodiet ipsos custodes?*
> >
> >
> >
> > On Thu, Sep 15, 2011 at 8:38 AM, sanfordm99 <sanfordm99@...> wrote:
> >
> > > **
> > >
> > >
> > > Hello,
> > >
> > > Has anyone figured this one out? The CancelEventHandler suggested here
> is
> > > not a boolean, it is a handler (ie to the closing event). So, it should
> be
> > > the args.Cancel = true (which is a property of the handler). This
> doesn't
> > > work for me either. Any ideas?
> > >
> > > Thanks,
> > > Mike
> > >
> > >
> > > --- In vantage@yahoogroups.com, Kunal Ganguly <kunal_vantage@> wrote:
> > > >
> > > > The second links says that you need to set the CancelEventHandler to
> true
> > > >
> > > > so... in pseudocode
> > > >
> > > > private form_closing() handles form.closing
> > > > [form.]CancelEventHandler = true
> > > > end sub
> > > >
> > > >
> > > > unless you call calling this sub somewhere else, you really don't
> need to
> > > do anything with the args variable.
> > > >
> > > > Thanks,
> > > > Kunal
> > > >
> > > >
> > > >
> > > >
> > > > ________________________________
> > > > From: drew.pete <drew.pete@>
> > >
> > > > To: vantage@yahoogroups.com
> > > > Sent: Tue, January 5, 2010 2:35:07 PM
> > > > Subject: [Vantage] Re: Cancel Form Closing
> > > >
> > > >
> > > > Kunal,
> > > >
> > > > Thanks for the links. After comparing both links I couldn't see why
> the
> > > following code I have wouldn't work...
> > > >
> > > > Private Sub JobEntryForm_ Closing(ByVal sender As object, ByVal args
> As
> > > System.ComponentMod el.CancelEventAr gs) Handles JobEntryForm. Closing
> > > >
> > > > args.Cancel = true
> > > >
> > > > End sub
> > > >
> > > > It doesn't error out at all for me - it just doesn't cancel the
> closing
> > > of the form.
> > > >
> > > > Thanks,
> > > > Drew
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > [Non-text portions of this message have been removed]
> > > >
> > >
> > >
> > >
> >
> >
> > [Non-text portions of this message have been removed]
> >
>
>
>



--
*Waffqle Driggers*
*High End Dev, System Design, Profit Drinking
*
*:: 904.962.2887*
*:: waffqle@...*
*:: NO FAXES*

*

*


[Non-text portions of this message have been removed]
Thanks everyone for the replies. Here is some sample code that I have tried. This compiles fine, but does not work. The form still closes. I am using Version 8.03.408B.


Private Sub UD101Form_Closing(ByVal sender As object, ByVal args As System.ComponentModel.CancelEventArgs) Handles UD101Form.Closing
'//
'// Add Event Handler Code
'//
args.Cancel = true
End Sub


The goal of this is for validation. Basically, after a message box, I want the user to have the option to not close the form. Anyone have any ideas?

Thanks,
Mike

--- In vantage@yahoogroups.com, Waffqle <waffqle@...> wrote:
>
> e.Cancel works for me as well.
>
> On Thu, Sep 15, 2011 at 8:55 AM, sanfordm99 <sanfordm99@...> wrote:
>
> > **
> >
> >
> > Thanks for the reply. I should have mentioned that I am on version 8 and
> > trying to do this for UD101. It is also VB (which shouldn't matter).
> >
> > Thanks,
> > Mike
> >
> >
> > --- In vantage@yahoogroups.com, Jose Gomez <jose@> wrote:
> > >
> > > This works fine for me
> > > private void QuoteEntryForm_FormClosing(object sender,
> > FormClosingEventArgs
> > > e)
> > > {
> > > e.Cancel = true;
> > > }
> > >
> > > *Jose C Gomez*
> > > *Software Engineer*
> > > *
> > > *
> > > *checkout my new blog <http://www.usdoingstuff.com> *
> > > *
> > > *T: 904.469.1524 mobile
> > > E: jose@
> >
> > > http://www.josecgomez.com
> > > <http://www.linkedin.com/in/josecgomez> <
> > http://www.facebook.com/josegomez>
> > > <http://www.google.com/profiles/jose.gomez> <
> > http://www.twitter.com/joc85>
> > > <http://www.josecgomez.com/professional-resume/>
> > > <http://www.josecgomez.com/feed/>
> > > <http://www.usdoingstuff.com>
> > >
> > > *Quis custodiet ipsos custodes?*
> > >
> > >
> > >
> > > On Thu, Sep 15, 2011 at 8:38 AM, sanfordm99 <sanfordm99@> wrote:
> > >
> > > > **
> > > >
> > > >
> > > > Hello,
> > > >
> > > > Has anyone figured this one out? The CancelEventHandler suggested here
> > is
> > > > not a boolean, it is a handler (ie to the closing event). So, it should
> > be
> > > > the args.Cancel = true (which is a property of the handler). This
> > doesn't
> > > > work for me either. Any ideas?
> > > >
> > > > Thanks,
> > > > Mike
> > > >
> > > >
> > > > --- In vantage@yahoogroups.com, Kunal Ganguly <kunal_vantage@> wrote:
> > > > >
> > > > > The second links says that you need to set the CancelEventHandler to
> > true
> > > > >
> > > > > so... in pseudocode
> > > > >
> > > > > private form_closing() handles form.closing
> > > > > [form.]CancelEventHandler = true
> > > > > end sub
> > > > >
> > > > >
> > > > > unless you call calling this sub somewhere else, you really don't
> > need to
> > > > do anything with the args variable.
> > > > >
> > > > > Thanks,
> > > > > Kunal
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > ________________________________
> > > > > From: drew.pete <drew.pete@>
> > > >
> > > > > To: vantage@yahoogroups.com
> > > > > Sent: Tue, January 5, 2010 2:35:07 PM
> > > > > Subject: [Vantage] Re: Cancel Form Closing
> > > > >
> > > > >
> > > > > Kunal,
> > > > >
> > > > > Thanks for the links. After comparing both links I couldn't see why
> > the
> > > > following code I have wouldn't work...
> > > > >
> > > > > Private Sub JobEntryForm_ Closing(ByVal sender As object, ByVal args
> > As
> > > > System.ComponentMod el.CancelEventAr gs) Handles JobEntryForm. Closing
> > > > >
> > > > > args.Cancel = true
> > > > >
> > > > > End sub
> > > > >
> > > > > It doesn't error out at all for me - it just doesn't cancel the
> > closing
> > > > of the form.
> > > > >
> > > > > Thanks,
> > > > > Drew
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > [Non-text portions of this message have been removed]
> > > > >
> > > >
> > > >
> > > >
> > >
> > >
> > > [Non-text portions of this message have been removed]
> > >
> >
> >
> >
>
>
>
> --
> *Waffqle Driggers*
> *High End Dev, System Design, Profit Drinking
> *
> *:: 904.962.2887*
> *:: waffqle@...*
> *:: NO FAXES*
>
> *
>
> *
>
>
> [Non-text portions of this message have been removed]
>
Did you get the answer??