Hi all,
I faced a weird problem and can't figure if this is a bug in framework 2.0
or I am just doing something totally wrong, maybe you guys can suggest
something.
I have a class inherited from System.Windows.Forms.Panel that adds a control
that has been passed to it to its collection of controls:
class SlidePanel : Panel
{
internal SlidePanel(Control _inner)
{
this.Controls.Add(_inner);
}
}
I figured that once some contolrs are added, they will change their size
(checkBoxList and ListBox) do this. For example, if I create a
checkedListBox with size(160,100), it will appear as (160,85).
Now, what happens is once the _inner is added, it will not reset its Size
attribute to the real size as it is on the form and remain 100. But, when I
put a break somewhere after adding the control to controls collection, and
navigate through the properties etc it will do this and the size will appear
correctly.
What I tried is this:
put a break somewhere after this.Controls.Add(_inner) and in the
intermediate window look at these properties:
_inner.Height (will return 100)
this.Controls[0].Height (I add only one and Controls.Count returns 1, so I
know I am looking at the same thing) will return 85.
I tried getting the Size via int sizeH = this.Controls[0].Height; but this
does not return the proper value anyway.
When I break on this line and browse through properties etc it will reset
the value tho.
Weird thing, does someone has an explanation to this?