Setting MDI Parent Size To Fit Around A Child Form

Hi,

How do you set the client size of an MDI parent to fit around a child form? 
Breakpoints in the constructor and load event handler show the child size to 
be already modified to fit into the parent; the child's size does not match 
what shows in the Designer.  I suppose the real question might be how do you 
determine the size of the child window or keep the parent from changing it 
first?

Thanks,
Gary 


0
Abby
12/28/2009 1:12:14 AM
dotnet.languages.csharp 1931 articles. 0 followers. Follow

3 Replies
2279 Views

Similar Articles

[PageSpeed] 48

What you're asking for is a little backwards, but I'm sure you  have your 
reasons.

At any rate, these are the properties you will want to investigate:

frmChild.Size
frmParent.ClientSize

and also frmParent.MdiChildren[] but I would resize the parent before the 
child is shown, in other words when the child is instantiated.

Any ToolBars, MenuBars or StatusStrips (or ???) that may be anchored in the 
frmParent will also need their height or width added to the size of frmChild 
before setting frmParent's ClientSize

I'm not completely sure, but you might also look into frmParent.AutoSize and 
frmParent.AutoSizeMode, if these will do what you want then it will be much 
more eloquent.

So with no other anchored controls in the parent form, your code will look 
something like this:

private void NewChildForm()
{
            Form child = new Form();
            child.MdiParent = this;

            this.ClientSize = child.Size;

            child.Show();
}



Good Luck,
-- 
Roger Frost
Logic Is Syntax Independent



"Abby Brown" <abbybrown@charter.net> wrote in message 
news:esXiJr1hKHA.5520@TK2MSFTNGP06.phx.gbl...
> Hi,
>
> How do you set the client size of an MDI parent to fit around a child 
> form? Breakpoints in the constructor and load event handler show the child 
> size to be already modified to fit into the parent; the child's size does 
> not match what shows in the Designer.  I suppose the real question might 
> be how do you determine the size of the child window or keep the parent 
> from changing it first?
>
> Thanks,
> Gary
> 
0
Roger
12/28/2009 2:03:46 AM
"Abby Brown" <abbybrown@charter.net> wrote in message 
news:esXiJr1hKHA.5520@TK2MSFTNGP06.phx.gbl...

> How do you set the client size of an MDI parent to fit around a child 
> form? Breakpoints in the constructor and load event handler show the child 
> size to be already modified to fit into the parent; the child's size does 
> not match what shows in the Designer.  I suppose the real question might 
> be how do you determine the size of the child window or keep the parent 
> from changing it first?

Rethink your design. Please. I know it requires more work, but make the 
child window flexible. Let it scroll, or rearrange its contents to fit the 
size of its parent, and not vice versa. If what you have is by necessity 
totally inflexible then I think MDI is probably not the direction you should 
be going in the first place. 


0
Jeff
12/28/2009 2:49:39 PM
"Jeff Johnson" <i.get@enough.spam> wrote in message 
news:Oh0$8z8hKHA.2188@TK2MSFTNGP04.phx.gbl...
> "Abby Brown" <abbybrown@charter.net> wrote in message 
> news:esXiJr1hKHA.5520@TK2MSFTNGP06.phx.gbl...
>
>> How do you set the client size of an MDI parent to fit around a child 
>> form? Breakpoints in the constructor and load event handler show the 
>> child size to be already modified to fit into the parent; the child's 
>> size does not match what shows in the Designer.  I suppose the real 
>> question might be how do you determine the size of the child window or 
>> keep the parent from changing it first?
>
> Rethink your design. Please. I know it requires more work, but make the 
> child window flexible. Let it scroll, or rearrange its contents to fit the 
> size of its parent, and not vice versa. If what you have is by necessity 
> totally inflexible then I think MDI is probably not the direction you 
> should be going in the first place.

It is not possible to change the design.  I solved the problem by setting 
the
parent size before setting the child to maximize.  Apparently, I was 
misreading
some of the watch numbers which exacerbated the situation.

Thanks to those who responded,
Gary


-1
Abby
12/28/2009 9:23:10 PM
Reply:

Similar Artilces:

Code to fill Word form for multiple records from Access
This is the code I've been working with, but it freezes Access: Private Sub Command66_Click() 'Print Physician Profile. Dim appWord As Word.Application Dim doc As Word.Document 'Avoid error 429, when Word isn't open. On Error Resume Next Err.Clear 'Set appWord object variable to running instance of Word. Set appWord = GetObject(, "Word.Application") If Err.Number <> 0 Then 'If Word isn't open, create a new instance of Word. Set appWord = New Word.Application End If Set rs = Db.OpenRecordset rst.Open Me.RecordSource, CurrentProject.Co...

Input a date using a Form Button.
Hi, Please help as I'm totally lost with this one! I'm doing a little project for work and I have come across a littl problem with a date input that I have set up using a Form Button. No this button once pressed enters the date just as I want, into th correct Cell (the buttons called "Todays Date") Now I have recorded macro so that the button executes the =TODAY() comand - which is fin untill the date changes!! As you can emagine I need the date to stay a it was when first pressed as its a database I'm trying to compile. Does this make any sense to you all?? I will...

How can I set Outlook, I have problems with that.
I Try to use Outlook in my PC but I don't have a clue to set Outlook, I know if I can set the program I see my mail bye Outlook but is difficult to me understand... please can you help me how to set the program step by step? Thanks... You will need the server names from your ISP in order to set it up. We cannot help you with that. Most ISPs will post instructions on how to setup Outlook Express (they will not support Outlook) but you can use the same information to set up Outlook account(s). --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion in...

Printing a report to fit on one page
How do I do this PLEASE. It keeps wanting to fit it onto 4 pages, regardless of how much I shrink the size of the report. How do I copy the MS word "fit to one page" function?? -- Thanks! mass I haven't tried this with Money yet, but I usually set my print driver to "fit-to-page" when I experience a program that doesn't seem to allow that function on its own. "mass" wrote: > How do I do this PLEASE. It keeps wanting to fit it onto 4 pages, regardless > of how much I shrink the size of the report. How do I copy the MS word "fit &...

Journal Form...?
On my computer at work, in the Outlook (Xp) Journal - form, the pull down for "Entry Type" is blank except for "Access, Excel, Power Point..." Where did the "Phone Call, Note, Fax, Meeting, etc..." go? How do I get the proper list back? I have tried [Help-Detect and Repair] I have tried Properties (in Form Design) but the first page of the Journal Form in design mode is null... The various Journal entry types are registry entries. See http://www.inquiry.com/techtips/exo_pro/10min/10min0999.asp for information about how to add custom entries. The same pr...

Set Focus 05-22-07
I have a command button that displays and filters 2 forms. I would like to set the focus to a specific field on another form when these are opened. TIA In news:1179848189.605344.149570@r3g2000prh.googlegroups.com, myxmaster@hotmail.com <myxmaster@hotmail.com> wrote: > I have a command button that displays and filters 2 forms. I would > like to set the focus to a specific field on another form when these > are opened. Something along the lines of: DoCmd.OpenForm "Form1", WhereCondition:="[SomeField]=1" DoCmd.OpenForm "Form2", WhereConditi...

open form with no data
Hi, I have a form on which i present al lot of data from a database. On the form is a comobox which i use to select the right record en present the data of this record on the form. When i open de form, de combobox is empty (which is good !) but the rest of the form is already filled with the data of a record in the database (which is not good). When i choose a record for the combobox, the form is filled with the data of that particular record (which is good). So the only problem i have is on opening the form. Is it possible to open the form without it being filled with data...

Picture-like frame around Reading Pane in Outlook 2003
If you got me, there's a dark-grey thick frame around Reading Pane in Outlook 2003. Who was that idiot designer which invented this?? Anyway, who knows how to get rid of this "cool feature". I hate it more than anything in my PC. Thanks, Serguei You can close the reading pane, but the border can't be removed or resized. View, reading pane, off. -- Diane Poremsky [MVP - Outlook] Author, Teach Yourself Outlook 2003 in 24 Hours Need Help with Common Tasks? http://www.outlook-tips.net/beginner/ Outlook 2007: http://www.slipstick.com/outlook/ol2007/ Outlook Tips by email: d...

How to set view titles in this scenario.
Hi My application always creates two view on file new, file open . Its a MDI application. I have refered following link. http://www.codeguru.com/cpp/w-d/doc_view/viewmanagement/article.php/c3275/ Problem is , when I execute the application, and new document is automatically created. But the both view titles remain same. I want them to be xxx1:1 and xxx1:2 but both of them display xxx1 only. This is not the case when I manually click file->new. How to set the proper view titles here. thanks leee. The link you mentioned does not work. If you are setting titile of MDI child frame, you can...

I can't set up my account on Windows Mail
Hi . I need help, I tried to set my email up on Windows mail using, gmail accounts, gmx and everything you could think. I worked on it for days but nothing ever worked. I'm pretty sure I put in the right POP and all. What else can I do? Does Gmail and gmx and all not work on a mail server on the actual desktop? Please help me? asiankelsey;1224241 Wrote: > Hi . I need help, I tried to set my email up on Windows mail using, > gmail > accounts, gmx and everything you could think. I worked on it for days > but > nothing ever worked. I'm pretty sure I put i...

Database size growing too fast
Hi, We just implemented RMS in our store 2 months ago. I have noticed that the size of the database is already past 1GB mark. Is this normal? Do I need to do anything (say archive records etc) to keep it under control? any help is appreciated. Regards JD We've been using RMS for about 18 months and our db is 250MB. Do you do a really high volume of transactions? We probably only do 30-50 on an average day. But I'm interested in an answer to your question too, since I know that MSDE is limited to 1GB database. "anonymous@discussions.microsoft.com" wrote: > Hi, &...

how can I attach a single access database form to an email
I want to attach a single database form to an email, im not sure if this is possible, Do you really mean a Form or a Report? Steve "tony" wrote: > I want to attach a single database form to an email, im not sure if this is > possible, Hi Steve, yes a report "SteveM" wrote: > Do you really mean a Form or a Report? > > Steve > > "tony" wrote: > > > I want to attach a single database form to an email, im not sure if this is > > possible, ...

Setting a rule to look for a word in the 'from' header?
Hi O' 20002 I can't seem to set a rule that looks for a word in the 'From' header in the inbox. It's the part that is in the 'Displayed Name' box when of the senders email address. Any Ideas? Thanks in advance Dave F. It is a standard Wizard Rule so what is the problem? Make sure that the peolpe in the rule are in your Address Book/Contacts folder as well. -- Roady www.sparnaaij.net Microsoft Office and Microsoft Office related News Also Outlook FAQ, How To's, Downloads and more... ----- "Dave F" <david.fox@burohappold.com> wrote in mes...

password protected to sub form
i have a form which don't want to be used by everyone.it should be protected with a password. i have Main form which calls many sub forms, one of the sub forms need to be protected with password. Below are the forms created in my database frmForm frmMain1 frmPassword frmForm has a command button(cmdDo) which calls Form(frmPassword). in frmPassword there is text box(PASSWORD),when i type password as A to my text box this should open my frmMain1 ...

Open form to specific record from button on continuous form
I have a continous form with limited data and I would like to have a button which then opens up a selected record in another form. I've placed the button via the wizard and, while it opens the form, it doesn't open to the selected record. It it possible to have a button on a continous form which would then open to a bookmarked record on another form? The wizard put this code, is it possible to modify this? Thanks. Private Sub btnOpenForm_Click() On Error GoTo btnOpenForm_Click_Err DoCmd.OpenForm "frmName", acNormal, "", """...

Xrefs from Form Fields not Visible
I've got a form that uses xrefs (bookmarks) to repeat field text elsewhere in the doc. Some of the xrefs are showing up as gray boxes, but not all are. The xrefs are functional even if invisible. Removing the \h switch from the xref fields and updating the field does not cause the field to become gray. The paragraph style is the same for both visible and invisible xrefs. I'd like them all to be shown as gray boxes so that my (tech-unsavvy) users can see that the fields are actually there. I do have Show Bookmarks (and Field Shading) checked ON in Word Options. Tha...

Creating a form from two tables
Im looking for assistance. This database is used for evaluations. so a manager completes a form that has 25 questions. They do 4 evaluations a month on each employee. I have 3 tables the Evaluation information (Table 1), The Answer Information (Table 2) and the Question Table (Table 3) Is there a way to popuplate at form that has all the Evaluation Information, lists each question from table 3 with the Answer Information for each of those questions from Table 2. I haven't begun creating this database yet so if there is a better way to do it i am open to suggestions. Tabl...

CRM Campaign Management Work-around in v1.2
Similar to the quick campaign in v3.0, is there a way to create a phone call activity for "multiple" contacts in v1.2? Afraid not. -- Matt Parks MVP - Microsoft CRM "CG" <CG@discussions.microsoft.com> wrote in message news:1DE52140-9144-4B2F-8EC9-9E1671DBB9A2@microsoft.com... Similar to the quick campaign in v3.0, is there a way to create a phone call activity for "multiple" contacts in v1.2? Well, you could create a manual workflow rule that simply creates an activity, and then from any grid in CRM, select "Actions | Apply Rule", and sel...

Prevent user from closing form -- form event
I have 2 buttons on my form. Button1 to import the data and Button2 to upload to database. I want user to click first on button1 and then next on button2 before closing the form. What form event I should use to prevent user from closing the form with out clicking on 2nd button? Thanks -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access/201004/1 You can use the Unload event. You can prevent the form closing by setting Cancel = True in the unload event. You will need a way to notify the form that uploading has finished. You can put a...

Setting cell tabulations( ranges) in excell
I would like to set a ranage for tabulation; the row starts with "Week day and ends with END". You can automatically tab from WEEK day to END but to speed things up I want the tab to go to the next row once it reaches" End". instead of going to the next empty cell on the same row. How can I set a tabulation range? Example: Week Day Date Shift Start Lunch In Lunch Out Shift End Wednesday 18-Aug-04 Thursday 19-Aug-04 If you select your cells (say B2:H999) first, you can tab between the cells in the selection. dizzy kay wrote: >...

Setting Up a Novel
I would like to write a book using Publisher 2002. How can I set this up to achieve optimum results in the shortest period of time. Thanks Barry MS Word would be a better option for the writing, thereafter using Publisher (maybe) to lay it out.. -- Mike Hall MS-MVP Windows Shell/User "Barry" <cbj97@yahoo.com> wrote in message news:ebL81lg%23GHA.2408@TK2MSFTNGP05.phx.gbl... >I would like to write a book using Publisher 2002. How can I set this up to >achieve optimum results in the shortest period of time. Thanks Barry > Barry, You should contact your...

Saving Report Print Settings in Access 2007
I've upgraded to Office 2007. I have several reports that I want to print using a certain printer, 2 sided and hole punched. I've used Page Setup to select the printer and properties I want. However, Access doesn't save my settings. According to the Help section, it should save the settings. What am I doing wrong? Yes, this is a bug in Access 2007. Microsoft has not promised, but we are hoping it is fixed when SP1 is released. In the mean time, I'm not aware of a solution, but is is possible to achieve the same effect by setting the Printer object to the right prin...

How do i create a record form out of each rows?
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Hi <br><br>I would like to transform rows into a record form. <br><br>Instead of info showing in rows <br><br>I want it to look like a description. <br><br>Example <br><br>Artist: Michael Jackson <br> Album: Thriller <br> Label: Epic <br> Code: EC-4782 <br><br>Thanks <br><br>Dom Hi Dom, it largely depends on what you want to do with the form. I would recommend using Word and its Mail Merge Manager to c...

How do I create new default color settings for charts in Excel?
I do not like the default color settings for my charts in Excel. I always end up modifying them extensively. I'd like to make as few changes as possible when my charts are created. Can I set new color defaults for charts created in Excel? Hi, You can set the colours for chart lines and fill. Menu Tools > Options. On the Color tab is a set of colours for Line and Fill. Cheers Andy pro user wrote: > I do not like the default color settings for my charts in Excel. I always end > up modifying them extensively. I'd like to make as few changes as possible > when my char...

Page Setting
I want to change Default page setting so whenever i open new or existance excel file my described settings should be apply on that file. Maaz 1. A macro to set up the page settings as you wish. 2. If you want a default solution for all NEW workbooks............ Open a new workbook. Customize as you wish. Note: you can set all sheet footers at the same time by "grouping" the sheets. Right-click on a sheet tab and "select all sheets". Set up a footer on the active sheet and will be done to all. Ungroup when setup is complete. File>Save As Type: scroll down to E...