How to resize a form

  • Thread starter Thread starter tim
  • Start date Start date
T

tim

VB 6: frame1.width = form1.width - 200
VB .NET: ?

Can someone please help with this simple line of code...thanks..
 
The size properties are the same as VB6.
Additionally, there's a "size" property that you can set all the size
attributes at once.

Isn't your code working this way?

-Jay
 
No, it doesn't seem to work. form1 doesn't seem to have a property of
'width'. Looks like it's underneath the size property, but not sure what
the syntax of the code is.
 
Is your form instantiated?
VB.NET doesn't have that "default instance" of objects like VB6...
 
tim said:
VB 6: frame1.width = form1.width - 200
VB .NET: ?

In addition to the other replies: Notice that VB.NET supports docking and
anchoring of controls (properties 'Anchor' and 'Dock') which make explicit
resize code unnecessary in most cases.
 
tim said:
VB 6: frame1.width = form1.width - 200
VB .NET: ?

Private Sub Form_Layout( ... ) Handles Form1.Layout
Me.Frame1.Width = Me.ClientSize.Width - 13 ' roughly
End Sub

Forms have an overall Size (including borders and title bar) and
a ClientSize, that just includes the "inner" bit that you can
[normally] play with.

Your 200 has shrunk to 13 because all measurements in VB.Net
are now in Pixels; Twips are dead and buried (and good riddance),
so all your offsets, like this, need to be 1/15th their previous size
(Screen.TwipsPerPixelX/Y notwithstanding).

HTH,
Phill W.
 
Tim,

I did not see it in thrhead

frame1.width = me.width - 200

I hope this helps?

Cor
 
Addendum:

I forgot to say that it's a bad idea to base control sizes on the form's
width, because this width includes the width of the borders which may vary
from system to system. Instead, base the controls' sizes on the client size
of the form ('Me.ClientSize.Width').
 
Ding...Ding....Phill is the man...

Phills reply worked perfect.


Phill. W said:
tim said:
VB 6: frame1.width = form1.width - 200
VB .NET: ?

Private Sub Form_Layout( ... ) Handles Form1.Layout
Me.Frame1.Width = Me.ClientSize.Width - 13 ' roughly
End Sub

Forms have an overall Size (including borders and title bar) and
a ClientSize, that just includes the "inner" bit that you can
[normally] play with.

Your 200 has shrunk to 13 because all measurements in VB.Net
are now in Pixels; Twips are dead and buried (and good riddance),
so all your offsets, like this, need to be 1/15th their previous size
(Screen.TwipsPerPixelX/Y notwithstanding).

HTH,
Phill W.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top