473,322 Members | 1,431 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.

Displaying MdiChild ToolStrip into MdiParent during runtime.

88 64KB
I have an MDI application containing an MdiParent form and few MdiChild forms. The MdiParent has a fixed MenuStrip, a fixed ToolStrip and a fixed StatusStrip. The MdiChild forms have one or more ToolStrips and a StatusStrip along with other controls in them. The ToolStrips and the StatusStrip of the MdiChild are generally hidden and are only shown when the form is opened in the MdiParent. Based on this scenario I have the following objectives:

1) When an MdiChild is opened in the parent, its ToolStrip(s) should be shown along with the fixed Menu and ToolStrip of the parent. Please note, I ‘m not talking about merging the ToolStrip of the child form to that of the parent. It should show the ToolStrip of the child below the fixed ones of the parent. However, the StatusStrip of the child should merge with that of the parent as usual.

2) When an MdiChild is closed, its ToolStrip(s) should be removed from the MdiParent. The StatusStrip should also be unmerged from that of the parent.

3) As multiple Mdi children can be opened, the ToolStrip(s) of the currently active MdiChild should be shown in the MdiParent and those of the child losing focus should be removed as usual. The same rule is applicable for the StatusStrips also.

What I tried to do is, take a ToolStripPanel in the MdiParent and place the fixed Menu and ToolStrip in it. Then, when the MdiChild is opened or gains focus, add its toolstrip(s) into the ToolStripPanel of the parent. Later when the form loses focus or is closed, remove its toolstrip(s) from the ToolStripPanel of the parent.

The handling of the StatusStrips is typically done by the Merge and RevertMerge methods of ToolStripManager class when the child form opens/gains focus and closes/loses focus respectively.

The relevant code example for one of the child forms follows:

Expand|Select|Wrap|Line Numbers
  1. Private Sub CustomerList_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
  2.         If Not MdiParent Is Nothing Then
  3.             Dim parent As Home = MdiParent
  4.             Dim lastIndex As Integer = Array.IndexOf(parent.ToolStripPanel1.Rows, parent.ToolStripPanel1.Rows.Last)
  5.             parent.ToolStripPanel1.Join(Me.ToolStrip1, lastIndex + 1)
  6.  
  7.             Me.ToolStrip1.Visible = True
  8.             ToolStripManager.Merge(Me.StatusStrip1, CType(Me.MdiParent, Home).StatusStrip1)
  9.         End If
  10. End Sub

Expand|Select|Wrap|Line Numbers
  1. Private Sub CustomerList_Deactivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Deactivate
  2.         If Not MdiParent Is Nothing Then
  3.             Dim parent As Home = MdiParent
  4.             Dim lastIndex As Integer = Array.IndexOf(parent.ToolStripPanel1.Rows, parent.ToolStripPanel1.Rows.Last)
  5.             Array.Clear(parent.ToolStripPanel1.Rows, lastIndex, 1)
  6.             parent.ToolStripPanel1.Controls.RemoveAt(lastIndex)
  7.  
  8.             ToolStripManager.RevertMerge(CType(Me.MdiParent, Home).StatusStrip1, Me.StatusStrip1)
  9.         End If
  10. End Sub
But the problem is, every time I try to close an MdiChild an ObjectDisposedException is thrown stating “Cannot access a disposed object. Object name: ‘Icon’”. The problem doesn’t arise while traversing through the various MdiChild forms. It doesn’t arise while closing the whole application also.

Also, I couldn’t find a way to unjoin items from a ToolStripPanel.

Please help in solving this problem. Also mention if there’s some better way to achieve the above three objectives.

Feel free to ask if I couldn’t make myself clear.

Regards!
Oct 28 '13 #1
0 1103

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Tom Rahav | last post by:
Hello. I use visual basic .net 2003 and Crystal Reports for creating win-reports. My question is if there is any possibility to set font properties (type, color and size) of a text control or...
1
by: Jeff N | last post by:
It it possible to change a button's or text box's font size during runtime? When I try to build my application with this code: this.ActiveControl.Font.Size = "8.25"; I get this error message:...
2
by: Newbie | last post by:
Hello! I'm trying to figure out how to do the following: I need to show a table (perhaps using DataGrids, repeaters or others) for each salesperson in the sales dept. But the no. of tables...
3
by: Newbie | last post by:
hi! i am able to upload files successfully. but i have one minor problem. files are uploaded correctly if the directory exists, it is throwing an exception if the directory doesnt exist. but the...
1
by: sageer | last post by:
I'm want retrieve a file, edit it and then copy it to a folder during runtime I'm trying to figure where exactly can I store these files in the ..NET solution so that I can access them during...
3
by: Sampson | last post by:
I have a question about enumeration and how to populate them during runtime. I am using vb.net but will happily take any advice in c# as well. Here is an example to help illustrate what I am...
5
by: batham | last post by:
Hi Gurus, How can I execute a script during runtime. Here is my code, so how do I execute the new script during runtime which should be a part of the 'topDiv'. Thanks Help is appreciated. -...
2
by: heelios.hantonei | last post by:
Hi, I'm currently writting an application and I was wondering if there was a way to declare a class friend of another during runtime? Thanks. Philippe Gagnon
0
by: ZackariyaYoosuf | last post by:
Hi, How can we set a form's MDIParent at runtime.I dont have the form in hand.I have only the form name (as string type) in my hand. First I have to call this form with the form name.Then I...
2
by: sagarbakliwal | last post by:
hi, I am new to this forum but i have received a lot of help reading through this forum. I am creating a VB.NET application for Patient Record Management. In this there are various combo boxes and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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.