Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / October 2004

Tip: Looking for answers? Try searching our database.

Odd closing problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
B. Chernick - 17 Oct 2004 05:59 GMT
I have a base form with a Cancel button (btnCancel) and a simple msgbox
routine.  I would like to have a routine closing check to prevent loss of
data.
 
    Dim i As Integer
       i = MsgBox("Exit?", MsgBoxStyle.YesNo + MsgBoxStyle.Question)
       If i = MsgBoxResult.Yes Then
           Me.DialogResult = DialogResult.Abort
           Me.Dispose()
       End If

I have another form that inherits from the base form.  In both parent and
decendent the Cancel button property of the form is set to (None).  

The problem is this.  Even given the above, even given that I've traced the
code and can see that the Me.dispose call is NOT being made when I click No,
the form still closes.  Any suggestions as to what I might be overlooking?
Sooraj PM - 17 Oct 2004 07:27 GMT
Hi

Call form.close when you press cancel button and form closing event you can
show the confirmation message:

Like:

   Dim i As Integer
       i = MsgBox("Exit?", MsgBoxStyle.YesNo + MsgBoxStyle.Question)
       If i = MsgBoxResult.Yes Then
           Me.DialogResult = DialogResult.Abort
           Me.Dispose()
       Else i = MSgBoxResult.No Then
           e.Cancel = True
       End If

Regards

Sooraj
Microsoft Community Star

> I have a base form with a Cancel button (btnCancel) and a simple msgbox
> routine.  I would like to have a routine closing check to prevent loss of
[quoted text clipped - 13 lines]
> code and can see that the Me.dispose call is NOT being made when I click No,
> the form still closes.  Any suggestions as to what I might be overlooking?
B. Chernick - 17 Oct 2004 14:55 GMT
Thanks!  That worked perfectly.

(Although I'm still curious about what was causing the close in my original
example.)

> Hi
>
[quoted text clipped - 34 lines]
> > code and can see that the Me.dispose call is NOT being made when I click No,
> > the form still closes.  Any suggestions as to what I might be overlooking?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.