1

我想这可能是一个容易回答的问题,但由于某种原因我无法让它工作

 Sub New(ByVal Sess As AudioSessionControl2)
    S_Session = Sess

    'Create the panel and position it.
    S_Panel.BackColor = Color.AliceBlue
    S_Panel.Width = 200
    S_Panel.Height = 40
    Dim Position As New Point(6, 19)
    If G_AppSessions.Count > 0 Then
        Position = Point.Add(G_AppSessions.Item(G_AppSessions.Count - 1).SessionPanel.Location, New Point(0, 45))
    End If
    S_Panel.Location = Position

    'Create a label which has the name of the process
    Dim S_PName As New Label
    S_PName.Text = "Test"
    S_PName.Dock = DockStyle.Left
    S_Panel.Controls.Add(S_PName)

    'Create a button to change volume
    Dim S_Save As New Button()
    S_Save.Text = "Save"
    AddHandler S_Save.Click, AddressOf Save_Click
    S_Save.Parent = S_Panel
    S_Panel.Controls.Add(S_Save)

    S_Volume.Parent = S_Panel
    S_PName.Parent = S_Panel

    MainForm.Controls.Add(S_Panel)
    S_Panel.Parent = MainForm.gb_Applications
End Sub

问题是,标签会显示,因为它停靠,但按钮不会。它只会显示它是否也停靠,这不是我想要的。这是用于创建动态 UI 的类的一部分,我可以在其中创建许多此类来为各种事物创建一堆面板。

4

1 回答 1

1

我看不到您设置标签或按钮位置的任何地方。您可能将它们都放在 0,0 处,并且标签位于按钮顶部,将其遮盖住。您是否尝试设置两个控件的位置,确保它们不重叠?

于 2013-09-17T12:51:45.350 回答