我想这可能是一个容易回答的问题,但出于某种原因,我无法让它工作
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的类的一部分,我可以在其中创建一些此类来为各种事物创建一组面板。
答案 0 :(得分:1)
我没有看到您设置标签或按钮位置的任何位置。您可能将它们都放在0,0,标签位于按钮的顶部,使其模糊不清。您是否尝试设置两个控件的位置,确保它们不重叠?