以下给出的代码内容; 需要3个面板和2个拆分器。但是,第二分离器(绿色)必须位于灰色和棕色面板之间。但在不正确的地方。有什么建议吗? 谢谢。
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Show()
Dim tmpSplitter As Splitter
Dim tmpPanel As Panel
Dim MainPanel As Panel
' This is main panel
'
MainPanel = New Panel
With MainPanel
.Name = "MainPanel"
.Dock = DockStyle.Fill
.BackColor = Color.LightGray
.BorderStyle = BorderStyle.Fixed3D
.Visible = True
End With
Me.Controls.Add(MainPanel)
' 1: First Top Panel and Splitter
'
tmpPanel = New Panel
With tmpPanel
.Name = "Panel1"
.Dock = DockStyle.Top
.BackColor = Color.Red
.Visible = True
End With
tmpSplitter = New Splitter
With tmpSplitter
.Name = "Split1"
.Dock = DockStyle.Top
.BackColor = Color.Blue
.Cursor = Cursors.HSplit
End With
Me.Controls.Add(tmpSplitter)
Me.Controls.Add(tmpPanel)
' 2: Second Panel added to the left side of the main panel
'
MainPanel.Dock = DockStyle.Right
MainPanel.Size = New Size(MainPanel.Width * 0.5, MainPanel.Height)
Dim btn As New Button
btn.Size = New Size(10, 50)
btn.Location = New Point(MainPanel.Location.X - btn.Width, MainPanel.Location.Y)
Me.Controls.Add(btn)
tmpPanel = New Panel
With tmpPanel
.Size = New Size(10, MainPanel.Height)
.Location = New Point(MainPanel.Location.X - .Width - 5, MainPanel.Location.Y)
.Name = "Panel2"
.Dock = DockStyle.Fill
.BackColor = Color.Brown
End With
' THIS SPLITTER IS NOT IN THE RIGHT PLACE. Must be between brown and gray panel
'
tmpSplitter = New Splitter
With tmpSplitter
.Size = New Size(5, MainPanel.Height)
.Location = New Point(MainPanel.Location.X - .Width, MainPanel.Location.Y)
.Name = "Split2"
.Dock = DockStyle.Right
.BackColor = Color.Green
.Cursor = Cursors.VSplit
End With
Me.Controls.Add(tmpSplitter)
Me.Controls.Add(tmpPanel)
End Sub
End Class
答案 0 :(得分:0)
多做一些研究并尝试解决问题的方法
Me.Controls.SetChildIndex (tmpSplitter, 0)
足以在最后一行写。谢谢您的贡献。