Re: Control's Validating Event and closing a Form by Ben
Ben
Thu Jan 22 14:03:12 CST 2004
Inside the Form Closing event method if you set the e.Cancel to true, it
should not allow the form to close. Setting the e.Cancel to true in the
Texbox validating event just stops the event message pipeline so that
Validated and Lostfocus are never reached in the event pipeline. Allowing
you to display a message and such.
Am I making sense or just confusing you more?
Hope I am helping...
"Greg" <greg@cds-am.net> wrote in message
news:eCZMAAS4DHA.3224@tk2msftngp13.phx.gbl...
> Why does the form close then when validation fails on the textbox and
> e.cancel is set to True?
>
> "Ben S. Stahlhood II" <ben[.dot.]stahlhood[.at.]intellified[.dot.]com>
wrote
> in message news:OiqAFeR4DHA.1816@TK2MSFTNGP12.phx.gbl...
> > Greg,
> >
> > The form object is a different sender then your textbox object. It used
> the
> > same type of event args, but it is not the same instance. The values
will
> > be different.
> >
> > I think that is what you were looking for... if not, sorry.
> >
> > Thanks for the reply on the No touch by the way. I understand about the
> > Sand Box and the CAS tool. I wanted to avoid an extra install by the
> client
> > was all.
> >
> > Thanks
> >
> >
> > "Greg" <greg@cds-am.net> wrote in message
> > news:%23j2hzHR4DHA.1752@tk2msftngp13.phx.gbl...
> > > We handle the Validating event for textboxes that are contained in a
> > > GroupBox, which is contained in a TabControl which is contained in a
> Form.
> > > If Validation on the textbox fails, we do this:
> > > e.Cancel = True
> > > Now, when we click "X' in the upper right corner, the form closes. We
> > > checked the forms closing event, and now e.Cancel = False.
> > > Why is e.Cancel = False on the Form close?
> > >
> > >
> >
> >
>
>