Problem w Font property in Custom Control

S

sadhu

Hi,
I'm developing a simple composite control with 2 child controls, a
Label and a TextBox. I expose easily many properties of the inner
controls, in the form i.e.:

BoxToolTip & LabelToolTip,
BoxForeColor & LabelForeColor,
BoxCssClass & labelCssClass...

but when I try to insert the BoxFont & LabelFont properties,
they correctly appears in the designer and it's apparently possible to
set them but no attribute like font-size="..." or font-family="..." is
wrote on the aspx page that holds the control. I can't set directly the
Font property of the child control, because it's readonly.

Here's the code:

[Browsable(true), Category("Appearance"), DefaultValue("")]
public FontInfo BoxFont
{
get
{
return box.Font;
}
set
{
FontInfo f = (FontInfo) value;
box.Font.Bold = f.Bold;
box.Font.Italic = f.Italic;
box.Font.Name = f.Name;
box.Font.Names = f.Names;
box.Font.Overline = f.Overline;
box.Font.Size = f.Size;
box.Font.Strikeout = f.Strikeout;
box.Font.Underline = f.Underline;
}
}

Thanx for yr kind answer

Silvano
 
L

lisa

You want to use the CopyFrom method for this. In your set, do like
this:

box.Font.CopyFrom(Value);

HTH,
Lisa
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,034
Messages
2,570,356
Members
47,002
Latest member
RobertoLip

Latest Threads

Top