How to resize controls when resizing of form in VB.NET

  • Thread starter Thread starter Mamatha
  • Start date Start date
M

Mamatha

Hi

i have two listview controls on my form one besides
another.When i resized the form ,i want to resize those
controls automatically along with the form.Where can i set
those properties in VB.NET or how can i do this...
If anyone knows please letme know,thanks in advance.


Mamatha
 
The anchor property is a good idea, but not if the controls are beside
each other. You're going to have to use the form_resize event if you
want to resize both controls. Assuming that you want both controls to
be the same width and butted up against each other, use something like

Try
If Me.WindowState = FormWindowState.Minimized Then Exit Sub
l_size = (me.width - control1.left - extra_right_space) / 2
control1.width = l_size
control2.width = l_Size
control2.left = control1.left + l_size
Catch ex As Exception
End Try

If you want to automatically size the controls to the vertical height
of the control, then use the anchor property for top and bottom. Let
the CLR do some of the work.

Play with some margin space to put a little real estate between the
controls.
 
Back
Top