vb.net mdi child title bar not hiding

纵饮孤独 提交于 2019-12-12 11:10:58

问题


I have an issue hiding the title bar of a mdi child form in maximized state within a mdi parent form in .NET.

Here's what I have at design & run time:

Here is the new() of my MDI child form:

Public Sub New(ByRef pParent As Form)
    MyBase.New()
    Me.MdiParent = pParent
    fParent = pParent
    Me.Text = ""
    Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
    Me.WindowState = FormWindowState.Normal
    Me.MinimizeBox = False
    Me.MaximizeBox = False
    Me.ControlBox = False
    Me.ShowIcon = False
    Me.ShowInTaskbar = False
    Me.SizeGripStyle = Windows.Forms.SizeGripStyle.Hide
    Me.Dock = DockStyle.Fill
End Sub

I've tried FormWindowState.Maximized and DockStyle.None instead but the result was the same.

On the parent container, to change from a child to another I use this function:

Protected Sub SetActiveScreen(ByVal pChildForm As tWizardForm)
    If pChildForm Is Nothing Then Exit Sub
    If fActiveScreen Is pChildForm Then Exit Sub

    Dim hg As New tHourglass
    Try
       fActiveScreen = pChildForm
       fActiveScreen.Show()
       fActiveScreen.BringToFront()
       For Each aForm In MdiChildren
          If aForm IsNot fActiveScreen Then aForm.Hide()
       Next
       fActiveScreen.Execute()
       UpdateCaption()
    Finally
       hg.Dispose()
    End Try    
End Sub

At design I've set the parent property IsMdiContainer = True.

Where did I go wrong or what have I missed ? Plus this kind of double buttons on the child title bar is really strange. When I click one of the maximize buttons I end up with the same result:

.

The resulting title bar buttons cannot be clicked.

Thank you for any help !


回答1:


Here is your exact answer. It will solve your problem.

Add a MenuStrip to MDI form and make it invisible (Visible = false)




回答2:


I got this to working by:

  1. Set the child Dock to Fill
  2. Set the child WindowState to Normal (this was the magic bullet)
  3. Use the Show method, not the Focus method



回答3:


Try moving

 Me.MaximizeBox = False

to the child form's Load event, this seemed to work in my project.




回答4:


try the following settings for the child forms.

  Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None


来源:https://stackoverflow.com/questions/24627295/vb-net-mdi-child-title-bar-not-hiding

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!