0

I can't figure out how to resize a panel, I can't find anything other than what I've tried. I have an if statement run whenever a checkbox is changed and depending on whether it is checked or not depends on the size of a panel. I know the if statement runs (and works properly) because it modifies some other attributes on other elements.

I've tried all these below:

pnl_selection.Size = New Size(90, 105)
pnl_selection.Size = New System.Drawing.Size(90, 105)
pnl_selection.Size = (90, 105)
pnl_selection.Height = 105
pnl_selection.Height += 105

(where pnl_selection is the name of my panel)

I've also played with anchor and dock a bit but they don't seem to do much.

Thanks :)

Edit: This is the entirety of the if statement sub - I know it's being called because the cmd_send.Visible = False/True works fine.

Private Sub LiveModeToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles LiveModeToolStripMenuItem.Click
    If LiveModeToolStripMenuItem.Checked Then
        cmd_send.Visible = False
        pnl_selection.Size = New Size(90, 105)
    Else
        cmd_send.Visible = True
        pnl_selection.Size = New Size(90, 65)
    End If
End Sub
Jamie Scott
  • 452
  • 4
  • 20
  • Where is your code were you resize the panel because *pnl_selection.Size = New Size(90, 105)* works perfectly fine – γηράσκω δ' αεί πολλά διδασκόμε Aug 30 '14 at 14:59
  • All the other statements seem to be correct. Are you sure your `If` statement is really working? The other problem could be that the panel is already the size 90x105. So setting it to the same wouldn't make any different. So try with different numbers. – Pradeep Kumar Aug 30 '14 at 16:06
  • Using the wrong form reference is a standard vb.net bug. Looks okay in the debugger, it actually modifies a panel that isn't visible. Add Me.Show() to the code. – Hans Passant Aug 30 '14 at 16:17
  • panels normally have the same back color as their parent, so it is hard to notice if it really changed the size. are you sure it is not changing its size? – bto.rdz Aug 30 '14 at 17:01
  • Elsewhere in the code, the panel's colour is changed. Good idea though :) – Jamie Scott Aug 30 '14 at 21:46

0 Answers0