PreferredSize

I have a custom control and would like to set the PrefferedSize property to be used in a layout routine. The property only has a 'set' method. Is there any way to 'convince' the base control to return a preferredsize of my controls choosing? Will this property be made settable?

Thanks,
Ray

[307 byte] By [RayManning] at [2007-12-16]
# 1
Control.PreferredSize only has a 'get' method, however you can override Control.GetPreferredSize and return a custom size.
DavidM.Kean at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 2
Perhaps this has changed in Beta2 but in Beta1, this property is not marked virtual. The documentation (Beta1 and msdn2.microsoft.com) seems to indicate it is not virtual as well. Can you please verify that in Beta2 it is marked virtual?

Thanks,
Ray

RayManning at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 3
The property PreferredSize is not virtual, however the method GetPreferredSize is.
DavidM.Kean at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 4

Override the GetPreferredSize method. The size passed in is a suggested size to fit into.

Jessica at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 5

GetPreferredSize is the Correct answer. The Documentation should note that the default implementation of PreferredSize calls GetPreferredSize with a size of 0.

- Ray

RayManning at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...