我几乎花了两个小时在这些控制上做尝试和错误。我需要些帮助。

这就是我的目标..。为了能把他们三个都靠在右边,X-Y在那个进度栏下.以及X下面的轨迹杆..。(我最大限度地利用了我的形式,所以我需要停靠它)除非你有一些能自动适应的很酷的技巧。
X和Y是标签。显示我的地图坐标。
然后在它们下面是一个TrackBar在一个Panel里面。
尝试解决方案-结果:
我没有得到我想要的..。有什么想法吗?
发布于 2013-12-18 10:16:38
将所有控件添加到FlowLayoutPanel中。
将面板的流动方向设置为"RightToLeft“。
Me.FlowLayoutPanel1.FlowDirection = FlowDirection.RightToLeft 在设计器中,选择面板中包含的所有控件,并将属性"FlowBreak“设置为"True”。
替代
您还可以创建自己的流面板。
Public Class MyFlowPanel
Inherits Panel
Protected Overrides Function CreateControlsInstance() As System.Windows.Forms.Control.ControlCollection
Return New ControlCollection(Me)
End Function
Private Sub EnsureLayout(sender As Object, e As EventArgs)
If (Not Me.isUpdatingLayout) Then
Me.UpdateLayout()
End If
End Sub
Private Sub NotifyControlIndexChanged(child As Control)
'This will cause some selection issues in designer.
'Implement a custom designer to fix this.
Me.UpdateLayout()
End Sub
Protected Overrides Sub OnControlAdded(e As System.Windows.Forms.ControlEventArgs)
AddHandler e.Control.SizeChanged, New EventHandler(AddressOf Me.EnsureLayout)
AddHandler e.Control.LocationChanged, New EventHandler(AddressOf Me.EnsureLayout)
AddHandler e.Control.Resize, New EventHandler(AddressOf Me.EnsureLayout)
AddHandler e.Control.MarginChanged, New EventHandler(AddressOf Me.EnsureLayout)
MyBase.OnControlAdded(e)
Me.UpdateLayout()
End Sub
Protected Overrides Sub OnControlRemoved(e As System.Windows.Forms.ControlEventArgs)
RemoveHandler e.Control.SizeChanged, New EventHandler(AddressOf Me.EnsureLayout)
RemoveHandler e.Control.LocationChanged, New EventHandler(AddressOf Me.EnsureLayout)
RemoveHandler e.Control.Resize, New EventHandler(AddressOf Me.EnsureLayout)
RemoveHandler e.Control.MarginChanged, New EventHandler(AddressOf Me.EnsureLayout)
MyBase.OnControlRemoved(e)
Me.UpdateLayout()
End Sub
Protected Overrides Sub SetBoundsCore(x As Integer, y As Integer, width As Integer, height As Integer, specified As System.Windows.Forms.BoundsSpecified)
MyBase.SetBoundsCore(x, y, width, height, specified)
Me.UpdateLayout()
End Sub
Private Sub UpdateLayout()
Me.isUpdatingLayout = True
Dim top As Integer = Me.ClientRectangle.Top
Dim right As Integer = Me.ClientRectangle.Right
Dim c As Control
For index = 0 To (Me.Controls.Count - 1)
c = Me.Controls.Item(index)
top += c.Margin.Top
c.Location = New Point((right - (c.Width + c.Margin.Right)), top)
top += (c.Height + c.Margin.Bottom)
Next
Me.isUpdatingLayout = False
End Sub
Private isUpdatingLayout As Boolean
Public Shadows Class ControlCollection
Inherits Panel.ControlCollection
Public Sub New(owner As MyFlowPanel)
MyBase.New(owner)
Me.owner2 = owner
End Sub
Public Overrides Sub SetChildIndex(child As System.Windows.Forms.Control, newIndex As Integer)
MyBase.SetChildIndex(child, newIndex)
Me.owner2.NotifyControlIndexChanged(child)
End Sub
Private owner2 As MyFlowPanel
End Class
End Classhttps://stackoverflow.com/questions/20653818
复制相似问题