2 Attachment(s)
[RESOLVED] [2005] form not opening right
I changed the MainMenuStrip property to menuStrip1 and since then, I've been having problems with the way forms open and close. On load, the form opens up half way instead of filling the whole screen. The window state is maximized but it continues to open half way. The first picture is how the form is opening and the second picture shows how the form is supposed to open.
Attachment 60437
Attachment 60438
Also, I keep getting an error message: Cannot access a disposed object.
Object name: 'Icon'. when I try to close the forms.
Can somebody please help!!!!???? :blush:
Re: [2005] form not opening right
The form is maximizing.... the panel is not.... try making sure your panel is set to Dock = Fill... or anchor it to all sides (I'd go with dock=fill).
As for the other error, with out knowing what code is running, can't help you. But it sounds like you're tryign to clear out an Icon for an object (presumably the form) after it's been disposed of.
-tg
Re: [2005] form not opening right
I assume you have tried rebuilding your solution and closing and reopening the form designer window?
Re: [2005] form not opening right
I don't have a panel on the form.
The code I am trying to run is
vb Code:
For Each frms As Form In Me.MdiChildren
frms.Close()
Next
Re: [2005] form not opening right
did you add this menustrip1 to the MDI parent or the MDI child form?
as for your dispose error try this:
Code:
For Each frms As Form In Me.MdiChildren
if not frms.IsDisposed then
frms.close
end if
Next
Re: [2005] form not opening right
It is on the MDI Parent and no menustrip is specified for the rest of the child forms.
I will try your code, thanks!
Re: [2005] form not opening right
I don't really have a reason why it is happening, but it appears to be some sort of bug.
How I was able to get it to work though, was to NOT set the child forms windowstate to maximized at design time (leave it as normal) but then when you actually create an instance and show the form, set it to maximized in code before showing it..
IE in the MDI parent:
Code:
Dim F As New frmChild
F.MdiParent = Me
F.WindowState = FormWindowState.Maximized
F.Show()
Re: [2005] form not opening right
ok, i will try that and see how it works for me. thanks a bunch!
Re: [2005] form not opening right
Quote:
Originally Posted by kleinma
did you add this menustrip1 to the MDI parent or the MDI child form?
as for your dispose error try this:
Code:
For Each frms As Form In Me.MdiChildren
if not frms.IsDisposed then
frms.close
end if
Next
That didn't work, I still get the same error message. :(
Re: [2005] form not opening right
Quote:
Originally Posted by kleinma
I don't really have a reason why it is happening, but it appears to be some sort of bug.
How I was able to get it to work though, was to NOT set the child forms windowstate to maximized at design time (leave it as normal) but then when you actually create an instance and show the form, set it to maximized in code before showing it..
IE in the MDI parent:
Code:
Dim F As New frmChild
F.MdiParent = Me
F.WindowState = FormWindowState.Maximized
F.Show()
I did the exact same thing but the form just flickers multiple times and never opens.
Re: [2005] form not opening right
This may sound stupid... but I'm going to ask anyways.... what's the border style for the form?
-tg
Re: [2005] form not opening right
It's sizable. I'm going to kick myself if this is what is causing the error!
Re: [2005] form not opening right
I changed it to Fixed single and it is working fine now but for some reason, when I added the mainmenustrip to the mdi parent, i can't close the child forms. It gets stuck on this:
[highlight = vb]
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing) 'gets stuck here when trying to close
End Sub
[/highlight]
Re: [2005] form not opening right
Interesting... I would have expected that to be the other way around... at least that part is solved.
As for the dispose problem.... don't know... .I don't normaly add the dispose code to my forms, so that's a little out of my element.
-tg