X = Y doesn't work!

  • Thread starter Thread starter Phillip Taylor
  • Start date Start date
P

Phillip Taylor

I have a panel which has a textbox and a picture box on it. When the
resize event of the panel fires, I have code:

Protected Overrides Sub OnResize(ByVal eventargs As
System.EventArgs)
MyBase.OnResize(eventargs)

textArea.Top = 0
textArea.Left = 0
textArea.Width = Me.Width - 18
textArea.Height = Me.Height <--- DOESN'T
WORK

icon.Height = 16
icon.Width = 16
icon.Top = 0
icon.Left = textArea.Width
End Sub

When I have the debugger over the line "textArea.Height = Me.Height",
I can see textArea's height is 13 and my height is 20, yet the after
the code is executed the textArea's height is still exactly the same.
It's been ignored.

I haven't set Docking, or Anchoring so I can't see why exactly the
code doesn't work.

Anyone?
 
Phillip said:
I have a panel which has a textbox and a picture box on it. When the
resize event of the panel fires, I have code:

Protected Overrides Sub OnResize(ByVal eventargs As
System.EventArgs)
MyBase.OnResize(eventargs)

textArea.Top = 0
textArea.Left = 0
textArea.Width = Me.Width - 18
textArea.Height = Me.Height <--- DOESN'T
WORK

Some Controls have their own, built-in limits that you can't get round
(IIRC, the ComboBox is one) but I don't know about this one.

Also:

Consider using Me.ClientSize.Height and Me.ClientSize.Width. Me.Height
& .Width are for the [Panel] Control as a whole, Me.ClientSize.Height &
..Width represent the "inside" bit that you can put other controls onto.
If, later on, your panel were to acquire borders or some such thing,
using the ClientSize properties ensures that you won't find bits of your
TextBox disappearing "off the edges".

You shouldn't need to set the Location (Left & Top) every time - do this
once when you create the textArea Control and forget about it.

Use the Size property to adjust the control's height and width "in one
go", as in:

textArea.Size = Me.ClientSize

HTH,
Phill W.
 
Back
Top