PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
ShowDialog and this.Modal
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
ShowDialog and this.Modal
![]() |
ShowDialog and this.Modal |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Hi,
I'm working on a larger windows application in which I have a form that should behave as an mdi-child or as a dialog depending on how it is diplayed. I thought I'd display the form with ShowDialog() to get it modal and then at runtime check for this.Modal in the form and set some properties. This however, does not seem to work as this.Modal returns false even though I'm showing the form using its ShowDialog method. Here's the conditional mentioned above, just to show the idea. if (this.Modal) { this.ShowInTaskbar = false; this.MaximizeBox = false; this.MinimizeBox = false; this.FormBorderStyle = FormBorderStyle.FixedDialog; this.SaveButton.Visible = false; this.ChooseButton.DialogResult = DialogResult.OK; foreach (Control ctrl in this.Controls) ctrl.Left -= 72; } Thanks, -- Magnus Lindberg, MCSD, MCT |
|
|
|
#2 |
|
Guest
Posts: n/a
|
* "Magnus Lindberg" <magnus.lindberg@inospam> scripsit:
> I'm working on a larger windows application in which I have a form that should > behave as an mdi-child or as a dialog depending on how it is diplayed. I thought > I'd display the form with ShowDialog() to get it modal and then at runtime check > for this.Modal in the form and set some properties. > This however, does not seem to work as this.Modal returns false even though I'm > showing the form using its ShowDialog method. You cannot show a MDI child modally. -- Herfried K. Wagner [MVP] <http://www.mvps.org/dotnet> |
|
|
|
#3 |
|
Guest
Posts: n/a
|
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:%23I6oPkYvDHA.3532@TK2MSFTNGP11.phx.gbl... > * "Magnus Lindberg" <magnus.lindberg@inospam> scripsit: > > I'm working on a larger windows application in which I have a form that should > > behave as an mdi-child or as a dialog depending on how it is diplayed. I thought > > I'd display the form with ShowDialog() to get it modal and then at runtime check > > for this.Modal in the form and set some properties. > > This however, does not seem to work as this.Modal returns false even though I'm > > showing the form using its ShowDialog method. > > You cannot show a MDI child modally. > > -- > Herfried K. Wagner [MVP] > <http://www.mvps.org/dotnet> But in the case where the form is shown modally, it is not an MDI child. The application either sets the MdiParent property of the form and display it with Show(), or it doesn't bother with MdiParent and just calls ShowDialog(). The form, when displayed with ShowDialog is clearly modal since I can't interact with any other part of the application, yet this.Modal in the forms constructor returns false. I'm beginning to think that I have to check the Modal-property from outside of the form. -- Magnus Lindberg, MCSD, MCT cshrp.net - "Elegant code by witty programmers" |
|
|
|
#4 |
|
Guest
Posts: n/a
|
Maybe try checking the mdiParent property for the same logic?
Just a thought... -- Eric Newton C#/ASP Application Developer http://ensoft-software.com/ eric@cc.ensoft-software.com [remove the first "CC."] "Magnus Lindberg" <magnus.lindberg@inospam> wrote in message news:OYyXPuYvDHA.1744@TK2MSFTNGP12.phx.gbl... > "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message > news:%23I6oPkYvDHA.3532@TK2MSFTNGP11.phx.gbl... > > * "Magnus Lindberg" <magnus.lindberg@inospam> scripsit: > > > I'm working on a larger windows application in which I have a form that > should > > > behave as an mdi-child or as a dialog depending on how it is diplayed. I > thought > > > I'd display the form with ShowDialog() to get it modal and then at runtime > check > > > for this.Modal in the form and set some properties. > > > This however, does not seem to work as this.Modal returns false even though > I'm > > > showing the form using its ShowDialog method. > > > > You cannot show a MDI child modally. > > > > -- > > Herfried K. Wagner [MVP] > > <http://www.mvps.org/dotnet> > > But in the case where the form is shown modally, it is not an MDI child. > The application either sets the MdiParent property of the form and display it > with Show(), or it doesn't bother with MdiParent and just calls ShowDialog(). > The form, when displayed with ShowDialog is clearly modal since I can't interact > with any other part of the application, yet this.Modal in the forms constructor > returns false. > I'm beginning to think that I have to check the Modal-property from outside of > the form. > > > -- > Magnus Lindberg, MCSD, MCT > cshrp.net - "Elegant code by witty programmers" > > |
|
|
|
#5 |
|
Guest
Posts: n/a
|
Hi Magnus,
Why don't you just write your own Show method and set a flag before calling ShowDialog. Cheers Doug Forster "Magnus Lindberg" <magnus.lindberg@inospam> wrote in message news:OYyXPuYvDHA.1744@TK2MSFTNGP12.phx.gbl... > "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message > news:%23I6oPkYvDHA.3532@TK2MSFTNGP11.phx.gbl... > > * "Magnus Lindberg" <magnus.lindberg@inospam> scripsit: > > > I'm working on a larger windows application in which I have a form that > should > > > behave as an mdi-child or as a dialog depending on how it is diplayed. I > thought > > > I'd display the form with ShowDialog() to get it modal and then at runtime > check > > > for this.Modal in the form and set some properties. > > > This however, does not seem to work as this.Modal returns false even though > I'm > > > showing the form using its ShowDialog method. > > > > You cannot show a MDI child modally. > > > > -- > > Herfried K. Wagner [MVP] > > <http://www.mvps.org/dotnet> > > But in the case where the form is shown modally, it is not an MDI child. > The application either sets the MdiParent property of the form and display it > with Show(), or it doesn't bother with MdiParent and just calls ShowDialog(). > The form, when displayed with ShowDialog is clearly modal since I can't interact > with any other part of the application, yet this.Modal in the forms constructor > returns false. > I'm beginning to think that I have to check the Modal-property from outside of > the form. > > > -- > Magnus Lindberg, MCSD, MCT > cshrp.net - "Elegant code by witty programmers" > > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

