ToolStripManager.RevertMerge not working.

Troy

Well-known member
Joined
Feb 7, 2005
Messages
153
Programming Experience
10+
VB.NET:
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] frmBrowser_FormClosed([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Windows.Forms.FormClosedEventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].FormClosed[/SIZE]
[SIZE=2][COLOR=#008000]'RemoveHandler Me.Enter, AddressOf frmBrowser_Enter[/COLOR][/SIZE]
 
[SIZE=2]nWindow = nWindow - 1[/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] nWindow = 0 [/SIZE][SIZE=2][COLOR=#0000ff]And[/COLOR][/SIZE][SIZE=2] tbUpdatedFlag = [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]ToolStripManager.RevertMerge([/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].ParentForm.Controls([/SIZE][SIZE=2][COLOR=#a31515]"ToolStrip2"[/COLOR][/SIZE][SIZE=2]), ToolStrip1)[/SIZE]
[SIZE=2]tbUpdatedFlag = [/SIZE][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'MsgBox("There are " & nWindow & " windows open, and this is customer " & Me.Text & ", ID = " & Me.Tag)[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'AddHandler Me.Enter, AddressOf frmBrowser_Enter[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]

[SIZE=2][COLOR=#0000ff]
[/COLOR][/SIZE]

When I run my code it actually walks throught the process to revert the merge but it doesn't remove it?

Through debugging I watch it walk through and I open 3 children windows. As I close each window it skips the revert code as intended until nwindow = 0 then it walks throught the revert code like it should but my Toolstrip still has the child items merged after it closes the last child window.

and ideas?
 
A few ideas:
Try reversing the RevertMerge parameters, the order does matter, the first is the one to undo (target) and the second the one that was previously merged into it (source).
Also perhaps it is too late with the control when FormClosed, try FormClosing instead.
 
ok First they are in the correct order, the first is on my parent form and the second is from the child form I added to it.

second I tried placing it into the form closing proceedure also and well still nothing
 
You had this working here with mdi, what is different now? Is there a difference from what form (child/parent) you call code? Is the use of ParentForm property verified and also the 'ToolStrip2' control value? What exactly is the relationship with the frmBrowser code you posted above and the "3 children window" you mention? I'm not seeing the scenario you describe.
 
You had this working here with mdi, what is different now? Is there a difference from what form (child/parent) you call code? Is the use of ParentForm property verified and also the 'ToolStrip2' control value? What exactly is the relationship with the frmBrowser code you posted above and the "3 children window" you mention? I'm not seeing the scenario you describe.

ok the Browser form is my child form I have a child form with a browser control on it so I call the child frmBrowser.

My Parent form is frmMain.

When I create a child form, every child has the revert merge code in the closing field.

I only need to revert the frmMain(parent) toolbar if all the children are closed. I created a flag that is set once not only the number of Windows is <1 or equal to 0 but also if the Flag is true . once both these are met it will supposedly revert the menu to the original. Now I've stepped through my code and I watch as I close 2 open child windows and when they check the if statement they work as they are supposed too skipping the revert command because both criteria are not met.

When I close the third child it actually shows that the revert code is run but it does not change the Parent toolbar back to normal.

I'm trying to figure out why.

I'm having extreme difficulty manipulating children forms for some reason.

I just need a way to guaranteea tracking of the forms. one form per customer record that pops up after a tree select and when you select the form I want to be able to click a delete button and have it delete the correct form. but sometimes It looses track and even though it shows to be on one form it tries to delete a different form.

I'd be more than happy to let you examine my full code if you want just give me an e-mail and I'll upload it to you.

This Child form tracking is becoming a pain. I really wish they would have made it easier to keep tabs on a specific child form. I've even stored Customer id's in the .tag propery of the child forms to try to keep track but somehow they still get mixed up.
 
Last edited:
:) Just FYI I managed to fix it!
 
Really? Was it the spelling error?
 
hehe no I totally went through my code and redid it from scratch. Sometimes when I'm debugging I put a bunch of crud into it that causes more bugs than it's worth so I erased all of that code and started the routine from the beginning. All is Well!
 
Back
Top