Order of controls being added to panel, control not showing unless docked

I imagine this is probably an easy to answer question but for some reason I can't get it to work

 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

The problem is that, the label will show because its docked, but the button won't. It will only show if its docked as well, and thats just not what I want. This is part of a class for creating a dynamic UI, where I can create a number of this class to create a bunch of panels for various things.

Upvotes: 1

Views: 1067

Answers (1)

tcarvin
tcarvin

Reputation: 10855

I don't see anywhere where you are setting the label or button position. You probably have them both at 0,0 and the label is on top of the button, obscuring it. Did you try setting the position of both the controls, making sure they don't overlap?

Upvotes: 1

Related Questions