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

Re: PropertyGrid info by Jacob

Jacob
Mon Apr 26 16:02:13 CDT 2004

Emmet Cummings wrote:
> 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?

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



Re: PropertyGrid info by Emmet

Emmet
Thu Apr 29 11:36:22 CDT 2004


"Jacob Grass [MVP]" <JGrass@AbilitiSolutions.com> wrote in message
news:uNWW2G9KEHA.620@TK2MSFTNGP10.phx.gbl...
> Emmet Cummings wrote:
> > 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?
>
> 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
>
>


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