Bug or By Design...

  • Thread starter Thread starter Moshazu
  • Start date Start date
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
 
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.
 
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
 
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...
 
Back
Top