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

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
 
S

Shane

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.
 

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

Top