Groups | Blog | Home
all groups > dotnet windows forms > april 2004 >

dotnet windows forms : PropertyGrid info


Emmet Cummings
4/21/2004 11:59:00 PM
Hi,

I have a usercontrol that resizes itself based on the font size. When you
enter the font in the property grid the control resizes itself correctly in
design mode, but when the application is run, it uses the default font. So
my question is how do I get at the font entered in the property grid for
when I run the app. Where is that info stored?

Thanks,
Em

Jacob Grass [MVP]
4/26/2004 4:02:13 PM
[quoted text, click to view]

It sounds as though the Font change isn't being serialized, which is odd.
You'll need to implement two methods:

(code assumes that the property is named Font)

Private Sub ResetFont()
'Set the Font to the default value here
End Sub

Private Function ShouldSerializeFont() As Boolean
'Check the current value of the font versus the default. If they're
different, return True, else False.
End Function




--
Jacob Grass
Microsoft .NET MVP
Check out http://windowsforms.net

Emmet Cummings
4/29/2004 12:36:22 PM

[quoted text, click to view]


Thanks for the code, Jacob. The problem was that I was overriding the Font
property instead of listening for
FontChanged. The code helps for other properties though.

Thanks,
Em

AddThis Social Bookmark Button