Professional Web Applications Themes

Problem w Font property in Custom Control - ASP.NET Building Controls

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 ...

  1. #1

    Default Problem w Font property in Custom Control

    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 Guest

  2. #2

    Default Re: Problem w Font property in Custom Control

    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
    lisa@starways.net Guest

Similar Threads

  1. Custom control with complex property type (System.Web.UI.Control[])
    By Jeremy Chapman in forum ASP.NET Building Controls
    Replies: 0
    Last Post: February 15th, 06:00 PM
  2. Problem with Custom Web Control Property
    By Dexter in forum ASP.NET Building Controls
    Replies: 1
    Last Post: November 30th, 05:57 PM
  3. ASP.net 2.0 Custom Web Control Problem "could not be set on property "
    By Adam Rogas in forum ASP.NET Building Controls
    Replies: 0
    Last Post: September 14th, 11:34 PM
  4. Custom Control Font Property
    By Remy Samulski in forum ASP.NET Building Controls
    Replies: 3
    Last Post: November 20th, 10:10 AM
  5. Exposing Font Name Property for Custom Control
    By Deep S. in forum ASP.NET Building Controls
    Replies: 2
    Last Post: August 4th, 10:17 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139