Bug or By Design...

M

Moshazu

Take a look at the following code...

dim newLabel as new Label
with newLabel
.autosize = true
.text = "-00.00"
.autosize = false
end with


Previously, in VB.NET 2003, if I were to look at the WIDTH property
after I executed the above lines of code, I would be returned a width
of about 48.

Now, I am using VB.NET 2005, and looking at the same WIDTH property, I
now am always returned a width of 100.

Is this a bug in the new VS or is this by design? If by design, why is
it this way?

Thanks for any help all,
Darian
 
H

Herfried K. Wagner [MVP]

Moshazu said:
dim newLabel as new Label
with newLabel
.autosize = true
.text = "-00.00"
.autosize = false
end with


Previously, in VB.NET 2003, if I were to look at the WIDTH property
after I executed the above lines of code, I would be returned a width
of about 48.

Now, I am using VB.NET 2005, and looking at the same WIDTH property, I
now am always returned a width of 100.

Mhm. It seems that the line '.AutoSize = False' prevents the controls from
being automatically sized, although 'AutoSize' is set to 'True' at the time
a new text is assigned to the control. So I'd say that this behavior is not
by design.
 
C

Carlos J. Quintero [VB MVP]

Hi Darian,

I don´t have a definite answer, but you can use a tool like Reflector for
..NET (http://www.aisto.com/roeder/dotnet/) to see the internal
implementation of the Autosize property and compare in different versions of
the framework.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio 2005, Visual Studio .NET,
VB6, VB5 and VBA
You can code, design and document much faster in VB.NET, C#, C++ or VJ#
Free resources for add-in developers:
http://www.mztools.com
 
G

Guest

It looks like this is by design. The Width property still uses the base
Control Width property, but the AutoAdjustSize method (used internally by the
control) maintains its own width and height properties, seperate from the
Control ones.

What you're seeing with the return value of 100, is the default Width of the
control. If AutoSize changes the width, it no longer changes the Width
property, but changes an internally maintained preferredWidth field.

If I followed the code correctly...
 

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