Hello,
The provided example is unclear.
using System;
using System.Windows.Forms;
using System.Drawing;
publicclass MyControl : Control {
// Declare an instance of the Font class
// and set its default value to null.
private Font thefont = null;
// The MyFont property.
public Font MyFont {
// Note that the MyFont property never
// returns null.
get {
if (thefont != null) return thefont;
if (Parent != null) return Parent.Font;
return Control.DefaultFont;
}
set {
thefont = value;
}
}
publicbool ShouldSerializeMyFont() {
return thefont != null;
}
publicvoid ResetMyFont() {
MyFont = null;
}
}
I dont understand where we really set the font property on the control?
As the code is, no real change will happen on the custom control, cause no effective Font property is linked with the private member
thefont