Your problem could be that you're not actually overriding Autosize in your code (ie, in the same way that you're overriding Font or ForeColor).
I have actually removed that override some time ago when I saw that it wasn't working. I'll add it again now and test. Basically I want to replace the Label with some new label called: IWillNotAutoSizeLabel ;)
I basically hate the autosize property "on by default".
Thanks!
I've seen similar behaviour when setting certain properties of controls in the constructor of the form itself. They seem to revert back to their design-time defaults.
I notice you're already overriding the OnLoad method. Have you tried setting AutoSize = false there? Or are you mainly concerned with providing a default value of false?
I don't see this.AutoSize = false
in your constructor. Your class is marked as partial -- perhaps you have a constructor in another file with that line. The visual studio designer will call that parameterless constructor you've got there.
I spended a lot of time about it...
...this finally works! (my code is vb.net but is simple to convert it)
Private _Autosize As Boolean
Public Sub New()
_Autosize=False
End Sub
Public Overrides Property AutoSize() As Boolean
Get
Return MyBase.AutoSize
End Get
Set(ByVal Value As Boolean)
If _Autosize <> Value And _Autosize = False Then
MyBase.AutoSize = False
_Autosize = Value
Else
MyBase.AutoSize = Value
End If
End Set
End Property
By