473,322 Members | 1,398 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

MDI child forms

I've created a simple MDI application and have designated the Window menu to
keep track of the mdi children. When I first load an mdi child, it's caption
consists of "File: no file loaded" and this is what appears on the Window
menu.

Now, after the mdi child loads, I call a method to load a specifically named
file. At this point, the child changes it's caption to reflect the new file
name. Unfortunately, the Window menu does not update and remains fixed on
"File: no file loaded".

Is there some trick I'm missing to ensure that the Window menu gets updated
to reflect the new child window caption?

Incidentally, I've found that this problem does not happen in the
development environment, but always happens on the compiled application.
Opening a second child window usually sorts the problem out.

I've tried invalidating the Window menu item and tried refreshing the
MenuStrip, but without any success.

Thanks
Steve

Dec 16 '05 #1
4 10957
There should be a .Parent or .MDIParent property on your
child form. Set its caption to your value.

myform.MDIParent.Caption = "blah"

--
Robbe Morris - 2004/2005 Microsoft MVP C#
http://www.eggheadcafe.com/forums/merit.asp

"Steve Barnett" <no****@nodomain.com> wrote in message
news:OE******************@tk2msftngp13.phx.gbl...
I've created a simple MDI application and have designated the Window menu
to keep track of the mdi children. When I first load an mdi child, it's
caption consists of "File: no file loaded" and this is what appears on the
Window menu.

Now, after the mdi child loads, I call a method to load a specifically
named file. At this point, the child changes it's caption to reflect the
new file name. Unfortunately, the Window menu does not update and remains
fixed on "File: no file loaded".

Is there some trick I'm missing to ensure that the Window menu gets
updated to reflect the new child window caption?

Incidentally, I've found that this problem does not happen in the
development environment, but always happens on the compiled application.
Opening a second child window usually sorts the problem out.

I've tried invalidating the Window menu item and tried refreshing the
MenuStrip, but without any success.

Thanks
Steve

Dec 16 '05 #2
Sorry, not sure how this helps. It's not the caption of the parent window
that's wrong, it's the name that appears on the WindowList menu. Even though
I have a file loaded and the child window caption has been changed, when I
open the Window menu, the WindowList shows the "original" caption that the
child window had before I changed it.

Steve
"Robbe Morris [C# MVP]" <in**@eggheadcafe.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
There should be a .Parent or .MDIParent property on your
child form. Set its caption to your value.

myform.MDIParent.Caption = "blah"

--
Robbe Morris - 2004/2005 Microsoft MVP C#
http://www.eggheadcafe.com/forums/merit.asp

"Steve Barnett" <no****@nodomain.com> wrote in message
news:OE******************@tk2msftngp13.phx.gbl...
I've created a simple MDI application and have designated the Window menu
to keep track of the mdi children. When I first load an mdi child, it's
caption consists of "File: no file loaded" and this is what appears on
the Window menu.

Now, after the mdi child loads, I call a method to load a specifically
named file. At this point, the child changes it's caption to reflect the
new file name. Unfortunately, the Window menu does not update and remains
fixed on "File: no file loaded".

Is there some trick I'm missing to ensure that the Window menu gets
updated to reflect the new child window caption?

Incidentally, I've found that this problem does not happen in the
development environment, but always happens on the compiled application.
Opening a second child window usually sorts the problem out.

I've tried invalidating the Window menu item and tried refreshing the
MenuStrip, but without any success.

Thanks
Steve


Dec 16 '05 #3
Just in case anyone else struggles with this, I failed miserably to get the
window list managed for me automatically. In the end, I added a
DropDownOpening event handler in my MDI form load event:

MainMenu.MdiWindowListItem.DropDownOpening += new
EventHandler(this.UpdateWindowMenuList);

This causes the UpdateWindowMenuList method to run when I select the menu
assigned to contain the window list:

private void UpdateWindowMenuList(object sender, EventArgs e)
{
// The code to update the window list on the Window menu does not
appear
// to work - so I've cobbled this together.
Application.DoEvents();

foreach (ToolStripItem tsMenu in
MainMenu.MdiWindowListItem.DropDown.Items)
{
if (tsMenu is ToolStripMenuItem)
{
ToolStripMenuItem tsMenuItem = (ToolStripMenuItem)tsMenu;
if (tsMenuItem.IsMdiWindowListEntry)
{
// Work out the index of this form.
int iIndex = Int32.Parse(tsMenu.Text.Substring(1, 1)) - 1;

// Update the menu
tsMenuItem.Text = String.Format("&{0} {1}", iIndex + 1,
this.MdiChildren[iIndex].Text);
}
}
}
}

In this routine, I go look for each MDI child and adjust the caption in the
WindowList menu items.

It's probably not the best solution, but it seems to be working for me.

Steve
"Steve Barnett" <no****@nodomain.com> wrote in message
news:uf**************@TK2MSFTNGP14.phx.gbl...
Sorry, not sure how this helps. It's not the caption of the parent window
that's wrong, it's the name that appears on the WindowList menu. Even
though I have a file loaded and the child window caption has been changed,
when I open the Window menu, the WindowList shows the "original" caption
that the child window had before I changed it.

Steve
"Robbe Morris [C# MVP]" <in**@eggheadcafe.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
There should be a .Parent or .MDIParent property on your
child form. Set its caption to your value.

myform.MDIParent.Caption = "blah"

--
Robbe Morris - 2004/2005 Microsoft MVP C#
http://www.eggheadcafe.com/forums/merit.asp

"Steve Barnett" <no****@nodomain.com> wrote in message
news:OE******************@tk2msftngp13.phx.gbl...
I've created a simple MDI application and have designated the Window
menu to keep track of the mdi children. When I first load an mdi child,
it's caption consists of "File: no file loaded" and this is what appears
on the Window menu.

Now, after the mdi child loads, I call a method to load a specifically
named file. At this point, the child changes it's caption to reflect the
new file name. Unfortunately, the Window menu does not update and
remains fixed on "File: no file loaded".

Is there some trick I'm missing to ensure that the Window menu gets
updated to reflect the new child window caption?

Incidentally, I've found that this problem does not happen in the
development environment, but always happens on the compiled application.
Opening a second child window usually sorts the problem out.

I've tried invalidating the Window menu item and tried refreshing the
MenuStrip, but without any success.

Thanks
Steve



Dec 19 '05 #4
Steve,

Ran into the same problem. Tried about everything and in the end used your
solution. I've modified the code such that there won't be a problem when
there are more than nine open mdichildren.

here it is:

Private Sub mnuDocuments_DropDownOpening(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles mnuDocuments.DropDownOpening

Dim Idx As Integer = -1

For Each M As ToolStripItem In
MainMenu.MdiWindowListItem.DropDown.Items
If TypeOf M Is ToolStripMenuItem Then
With CType(M, ToolStripMenuItem)
If .IsMdiWindowListEntry Then
Idx += 1
.Text = (Idx + 1).ToString("&0") & " " &
MdiChildren(Idx).Text
End If
End With
End If
Next

End Sub

I've also left out the Appication.DoEvents stuff. Seems to work without it.

Greetings.
Jan 6 '06 #5

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

Similar topics

8
by: CJack | last post by:
hy, I have an mdi application, i create a child form and I want to know when a button is pressed while that child form is loaded. I have this code: private void frmTestBaby_KeyUp(object sender,...
3
by: James Spibey | last post by:
Hi, I have an MDI application which has aboout 10 child windows. The way the app needs to work is that only one window should be visible at a time and it should be maximized within the parent...
3
by: Maheshkumar.R | last post by:
Hi groups, How i can command over the MDI CHIlD forms created dynamically at runtime from PARENT. Let say, i have generated 5 mdichild forms, but i want to work with child form1 from MDI...
3
by: Lance | last post by:
I've noticed that controls that are contained in MDI child forms fail to raise MouseLeave events if the MDI child form's MdiParent property is set to Nothing (after it was set to an existing MDI...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
0
by: Bruin | last post by:
Hi All, I'm having a problem with MDI child forms when the reference to the MDI Parent is set in a Control library. (Sorry for the long post) I have an control library assembly which holds all...
2
by: Lenster | last post by:
Environment --------------- Visual Studio.NET 2003 Version 7.1.3088 ..NET Framework 1.1 Version 1.1.4322 SP1 XP Professional 5.1.2600 SP2 Build 2600 Problem Description...
0
by: Scott H. | last post by:
I have an MDI parent form that creates mdi child forms each of which are represented by a tab item. I use a third party control to generate the tabbed MDI child forms. Each tab or MDI child form...
13
by: Academic | last post by:
I have a MDI form, sometimes child forms and sometimes forms that are neither If I close the app the child forms closing and closed event happens followed by the Mdi form receiving the...
0
by: emalcolm_FLA | last post by:
Hello and TIA for any help with this non profit Christmas assistance project. I have an applicant (app history) and child (child history) tables (4 total). I need to grab the next available (in...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.