473,473 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to keep a WinForm.ShowDialog() within the App Main Container f

Hi,

The default behavior for Modal forms does not restrict it to go out of the
client area of the main MDI container form.

I would like to show a modal form and keep it within the application
container form as any other non-modal MDI form.
I am not able to assign the MDIParent as it give an exception.

I will appreciate any suggestions.

Carlos Lozano
www.caxonline.net

Nov 17 '05 #1
1 4187
Hi Mark,

It does restrict the form to the container form client area, but causes a
boucing effect that does not look well.

It seems better using the default behavior.

Thank you anyway.

Carlos

"Mark R. Dawson" wrote:
Hi Carlos,
I do not believe this is possible since by defining the form as modal it
is a top level form and cannot be contained in any other form.

One way to fake this at a really simple level (I would like to hear from
anyone if there is a better way of doing this )would be to check in the Move
event of the child form for boundary conditions compared to the owner form
and it they are outside the boundary then automatically move the form back
inside the owner.

i.e.
Form1_ButtonClick()
{
Form2 f = new Form2();
f.Owner = this;

//set the position of f to be inside the owner form so that when
//it is opened it is inside the owner.

f.ShowDialog();
}
//Inside Form2 class

private void Form2_Move(object sender, EventArgs e)
{
if(this.Left < this.Owner.Left)
{
this.Left = this.Owner.Left;
}

//same for right, top and bottom
}
Mark

"Carlos Lozano" wrote:
Hi,

The default behavior for Modal forms does not restrict it to go out of the
client area of the main MDI container form.

I would like to show a modal form and keep it within the application
container form as any other non-modal MDI form.
I am not able to assign the MDIParent as it give an exception.

I will appreciate any suggestions.

Carlos Lozano
www.caxonline.net

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: someone | last post by:
Hi, We are encountering a problem with the DTPicker. This is the situation: We have a DTPicker-control on a VB6 Active-X. The Active-X is used on a .NET winform. the problem: The .Net...
2
by: Tom | last post by:
Hi all In winform application I am trying to start 2 forms I am trying to show the 2nd winform on a separate thread. using Thread mainapp = new Thread(new ThreadStart(loadmainscm)); ...
6
by: nadeem_far | last post by:
Hello All, I am working on a .Net desktop application and I am having problem displaying a form. I am using C# and version 1.1 of the framework. here is how the code looks likes and I will...
1
by: No Sheds | last post by:
Hi I have an MDI application. I have a MDI child window within this application that shows another form using ShowDialog. This works fine, except that the final form shown with ShowDialog...
6
by: randy1200 | last post by:
I'm using Visual Studio 2005 and C#. I need to print a WinForm used for data entry as a graphic. In other words, I need to print the exact WinForm the user sees on the screen. I searched through...
5
by: Miro | last post by:
I will try my best to ask this question correctly. I think in the end the code will make more sence of what I am trying to accomplish. I am just not sure of what to search for on the net. I...
0
by: =?Utf-8?B?Sm9obk1TeXJhc29mdA==?= | last post by:
I've got a Windows Forms application. There is a form that may be shown by clicking a command button on either of 2 other forms. I use ShowDialog in all cases to get modal behavior. When the app...
2
by: Ronny | last post by:
I work with VS2005 and .NET FW ver. 3.0. I need to implement 3 to 4 panes in my form application. Is that possible? Is there a way for the user to configure in real time (the pane number)? Is...
21
by: Dan Tallent | last post by:
In my application I have a form (Customer) that I want to be able to open multiple copies at once. Within this form I have other forms that can be opened. Example: ZipCode. When the user enters...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.