|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Show Modal, then AgainHello Everyone,
VB.Net 2003 I would like to open a form (Form2) modally from Form1, then from Form2 display Form3 modally. It seems that once I open that third form and then close it, the second form also closes. How can I prevent that from happening? I am thinking that I have to create a "Modal Helper" that will open the desired form modally, wait for it to close and then return a result to the caller. Am I on the right track? TIA "AMDRIT" <amd***@hotmail.com> schrieb Did you set the Dialogresult property of the Button in which's Click event > Hello Everyone, > > VB.Net 2003 > > I would like to open a form (Form2) modally from Form1, then from > Form2 display Form3 modally. It seems that once I open that third > form and then close it, the second form also closes. How can I > prevent that from happening? you show Form3? Armin I manually set the dialogresult of each form, however; I fail to see how
setting the value (which is Cancel by default) would terminated the modal dialog of the previous form. Private Sub cmdOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOk.Click Me.DialogResult = DialogResult.OK Me.Close() End Sub Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click Me.DialogResult = DialogResult.Cancel Me.Close() End Sub Show quoteHide quote "Armin Zingler" <az.nospam@freenet.de> wrote in message news:%23GQ0KJRIGHA.3944@tk2msftngp13.phx.gbl... > "AMDRIT" <amd***@hotmail.com> schrieb >> Hello Everyone, >> >> VB.Net 2003 >> >> I would like to open a form (Form2) modally from Form1, then from >> Form2 display Form3 modally. It seems that once I open that third >> form and then close it, the second form also closes. How can I >> prevent that from happening? > > > Did you set the Dialogresult property of the Button in which's Click event > you show Form3? > > > Armin >From the docs for DialogResult (emphasis mine): The dialog result of a form is the value that is returned from the formwhen it is displayed as a modal dialog. Note this part: If the form is displayed as a dialog box, setting this property with a value from the DialogResult enumeration sets the value of the dialog result for the form, hides the modal dialog, and returns control to the calling form. I removed all the logic for setting the dialog result, now the button clicks
(Ok, and Cancel) now just call Me.Close(). The behavior is the same. The first form is a mdi child of an mdi parent, i wonder if this makes a difference. MDI Parent opens mdi child (A listview of data), from there, I open the details view (Form2) modally, and finally one property requires yet another form to capture the data so I open that modally. I wonder if the mdi child is the issue? Show quoteHide quote "Chris Dunaway" <dunaw***@gmail.com> wrote in message news:1138127950.833554.185990@z14g2000cwz.googlegroups.com... > >From the docs for DialogResult (emphasis mine): > > The dialog result of a form is the value that is returned from the form > when it is displayed as a modal dialog. > > Note this part: > > If the form is displayed as a dialog box, setting this property with a > value from the DialogResult enumeration sets the value of the dialog > result for the form, hides the modal dialog, and returns control to the > calling form. >
Show quote
Hide quote
"AMDRIT" <amd***@hotmail.com> schrieb I don't see where you show another form in one of these events handlers.> I manually set the dialogresult of each form, however; I fail to see > how setting the value (which is Cancel by default) would terminated > the modal dialog of the previous form. > > > Private Sub cmdOk_Click(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles cmdOk.Click > Me.DialogResult = DialogResult.OK > Me.Close() > End Sub > > Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e > As System.EventArgs) Handles cmdCancel.Click > Me.DialogResult = DialogResult.Cancel > Me.Close() > End Sub Armin I was illustrating what I was doing on form close in response to your post.
Here is what I am doing: open frmMain open frmList as MDIChild modally open frmListEdit modally open frmMoreDetail Public Class frmMain 'Set as MDI Container Private Sub cmdList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdList.Click dim f as frmList f = new frmList f.mdiparent = me addhandler f.closed, addressof frmList_Closed End Sub Private sub frmList_Closed(ByVal sender As Object, ByVal e As System.EventArgs) dim f as frmList f= ctype(sender, frmList) trace.writeline("List closed") f.dispose End Sub End Class Public Class frmList Private Sub cmdEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdEdit.Click dim f as frmListEdit f = new frmListEdit f.showdialog(me) trace.write("List Edit Closed") f.dispose() End Sub End Class Public Class frmListEdit Private Sub cmdMoreDetail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdMoreDetail.Click dim f as frmMoreDetail f = new frmMoreDetail f.showdialog(me) trace.write("More Detail Closed") f.dispose() End Sub Private Sub cmdClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdClose.Click me.close() End Sub End Class Public Class frmMoreDetail Private Sub cmdClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdClose.Click me.close() End Sub End Class Show quoteHide quote "Armin Zingler" <az.nospam@freenet.de> wrote in message news:erGyc8RIGHA.1180@TK2MSFTNGP09.phx.gbl... > "AMDRIT" <amd***@hotmail.com> schrieb >> I manually set the dialogresult of each form, however; I fail to see >> how setting the value (which is Cancel by default) would terminated >> the modal dialog of the previous form. >> >> >> Private Sub cmdOk_Click(ByVal sender As System.Object, ByVal e As >> System.EventArgs) Handles cmdOk.Click >> Me.DialogResult = DialogResult.OK >> Me.Close() >> End Sub >> >> Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e >> As System.EventArgs) Handles cmdCancel.Click >> Me.DialogResult = DialogResult.Cancel >> Me.Close() >> End Sub > > I don't see where you show another form in one of these events handlers. > > > Armin What's the value of the Dialogresult property of frmList.cmdEdit and
frmListEdit.cmdMoreDetail? Armin Since, I didn't set a value in the code i provided, the result would be
cancel. I still fail to see how the result has anything to do with my issue. The issue is, when I open a form modally from a form that was open modally and then close that form the original modal form is also closed. I do not want the original modal form to close until the user has completed using it. My work around, as cheap as it is, so far: Place a flag on the original modal form, and in the closing event check set e.cancel to the flag, and then toggle the flag off. Each time before opening a new form modally from the original modal form I set the flag to true. Just seems wrong to have to manage a flag when nothing asked the form to close to begin with, and yet I need to continue to complete the task at hand. Show quoteHide quote "Armin Zingler" <az.nospam@freenet.de> wrote in message news:ux2fQzSIGHA.2300@TK2MSFTNGP15.phx.gbl... > > What's the value of the Dialogresult property of frmList.cmdEdit and > frmListEdit.cmdMoreDetail? > > > Armin "AMDRIT" <amd***@hotmail.com> schrieb You didn't answer my question. Maybe you set the Dialogresult value in the> Since, I didn't set a value in the code i provided, the result would > be cancel. I still fail to see how the result has anything to do > with my issue. designer? If the Dialogresult property of frmList.cmdEdit or frmListEdit.cmdMoreDetail has been set in the designer, the Form would be closed after the modal Form has been shown. This would explain the problem. For example, in cmdEdit_Click, you show frmListEdit. After frmListEdit has been closed, the instance of frmList will be closed, too. That's what you don't want, and that's why I ask what the value of the Dialogresult property of frmList.cmdEdit and frmListEdit.cmdMoreDetail is. Armin I now understand what you were asking me. I didn't realize the the
commandbuttons had a dialogresult property on them, the buttons on the last form (frmMoreDetail) had been set to cancel. Thank you for your patience. Show quoteHide quote "Armin Zingler" <az.nospam@freenet.de> wrote in message news:e8xtHRTIGHA.1312@TK2MSFTNGP09.phx.gbl... > "AMDRIT" <amd***@hotmail.com> schrieb >> Since, I didn't set a value in the code i provided, the result would >> be cancel. I still fail to see how the result has anything to do >> with my issue. > > You didn't answer my question. Maybe you set the Dialogresult value in the > designer? If the Dialogresult property of frmList.cmdEdit or > frmListEdit.cmdMoreDetail has been set in the designer, the Form would be > closed after the modal Form has been shown. This would explain the > problem. > > For example, in cmdEdit_Click, you show frmListEdit. After frmListEdit has > been closed, the instance of frmList will be closed, too. That's what you > don't want, and that's why I ask what the value of the Dialogresult > property of frmList.cmdEdit and frmListEdit.cmdMoreDetail is. > > > Armin > "AMDRIT" <amd***@hotmail.com> schrieb But the last form isn't the problem. :-) The problem is that frmList and>I now understand what you were asking me. I didn't realize the the >commandbuttons had a dialogresult property on them, the buttons on the last >form (frmMoreDetail) had been set to cancel. > > Thank you for your patience. frmListEdit are closed unintentionally, isn't it? Thus, I /still/ wonder what's the value of the dialogresult property of frmList.cmdEdit and frmListEdit.cmdMoreDetail. These are the buttons that show a modal form. Please select each of these two buttons in the designer and have a look at their dialogresult property. What is the value? Maybe you accidently set them when copying buttons in the designer. Again, for example, if you set cmdMoreDetail.Dialogresult (in frmListEdit) to Dialogresult.Ok (in the designer), clicking the button means: 1. The Dialogresult property of the form (frmListEdit) is set to Dialogresult.Ok. This is done automaticall because this is the value of the buttons's Dialogresult property. 2. cmdMoreDetail_Click is raised. In the event handler, you show and close frmMoreDetail. 3. frmListEdit ist closed! This is an automatic mechanism: If the Form's Dialogresult property value has been set to a value different from Dialogresult.None - this happened in step 1 - the Form is closed automatically. In this case you return to frmList because showdialog, within cmdEdit_Click, returns. Armin
Get associated icon for a file
A question about finding class methods in the Help WEBREQUEST AND WEBRESPONSE PROBLEM URGENT: Problem when iterating through a custom collection (dictionary based) with FOR...EACH Assigning a Value to a Structure Pointed to by a Tag ? VB.NET profiler Problem when iterating through custom dictionary based collection with FOR...EACH...NEXT Process output redirection? Using a VB.net dll in VB6 How to know if a file is ready. |
|||||||||||||||||||||||