Resize before Load?

R

Rob Richardson

Greetings!

I have a form with a listview, a menu, and a few text boxes, labels and
command buttons. I want to resize the listview when the form is resized to
that the widths of the spaces between the borders of the listview and the
borders of the form remain constant. I am finding this to be unexpectedly
hard. For one thing, I initialized some values in the form's Load event,
and I'm doing the control resizing in the form's Resize event. But I am
finding that the Resize event fires first! Actually, the Resize event fires
four times before the form's Load event! How can this be?

Thanks!

Rob, who obviously has some fundamental flaws in his understanding of event
sequences.
 
P

Patrick Steele [MVP]

I have a form with a listview, a menu, and a few text boxes, labels and
command buttons. I want to resize the listview when the form is resized to
that the widths of the spaces between the borders of the listview and the
borders of the form remain constant. I am finding this to be unexpectedly
hard.

Instead of doing it with events, look into the Anchor and Dock
properties of your form.
 
R

Rob Richardson

Patrick,

Thanks for the tip. I will look into those properties.

But could you please explain why I'm getting resizes before loads? I'm
afraid that if I don't understand that, I'm going to get bitten in
uncomfortable locations on repeated occasions.

Thanks!

Rob
 
C

Cor Ligthert

Hi Rob,

You can open the design part of the code in a form by pushing on the + in
the code.
There you will see a lot of coding accoording *me.* that is the form, there
are as well settings that affects the size setting itself however as well
thinks as border which can be different, have a look at that, I hope you
will understand it than more?

When not, feel free to reply?

Cor
 
V

VJ

The resize event does fire before load, that is windows sequence of events,
its given. It fires 4 times.. that is interesting.. maybe your resize code
is causing it to do that..

if you want not to fire the resize, set a boolean variable make it false in
the form constructor, then set it to true after the Load event's last line
of code. Use this boolean to drive your code in resize.

Private Sub New()
{
blnVariable = false
Intialziecomponent()
..
}

Private sub Form1_Load(...)..
{
'Code starts here...

'Last Line of Code..
blnVariable = true
}

Private Sub Form1_Resize (... )..
{
if blnVariable then
'execute resize code.. here..
end if


}

VJ
 

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