Problem w Font property in Custom Control

Discussion in 'ASP .Net Building Controls' started by sadhu, May 22, 2005.

  1. sadhu

    sadhu Guest

    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
     
    sadhu, May 22, 2005
    #1
    1. Advertising

  2. sadhu

    Guest

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

    box.Font.CopyFrom(Value);

    HTH,
    Lisa


    sadhu wrote:
    > 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
     
    , May 23, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. silverprox
    Replies:
    0
    Views:
    551
    silverprox
    May 22, 2005
  2. mttc
    Replies:
    2
    Views:
    2,408
    Roedy Green
    Jul 3, 2009
  3. Deep S.

    Exposing Font Name Property for Custom Control

    Deep S., Aug 4, 2003, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    183
    Deep S.
    Aug 4, 2003
  4. Remy Samulski

    Custom Control Font Property

    Remy Samulski, Nov 19, 2003, in forum: ASP .Net Building Controls
    Replies:
    3
    Views:
    174
    Nenad Prekupec
    Nov 20, 2003
  5. Rob Joosen

    Keep custom property-value in custom rendered control

    Rob Joosen, May 12, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    147
    Rob Joosen
    May 12, 2004
Loading...

Share This Page