Problem w Font property in Custom Control

Ask a Question related to ASP.NET Building Controls, Design and Development.

  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. Similar Questions and Discussions

    1. Custom control with complex property type (System.Web.UI.Control[])
      I've built a control with a property of type System.Web.UI.Control. I have a custom editor which allows me to add items to this collection at...
    2. Problem with Custom Web Control Property
      Hello all, I'm developing a custom web control that mount a webpage, but now i don't can to modify the properties of my custom web control. by...
    3. Keep custom property-value in custom rendered control
      Hi there, here's the thing I have a custom control (rendered) with a label, textbox and some validators. I use that for entering a birthdate, to...
    4. Custom Control Font Property
      Dear readers, Have a web custom control going but can't seem to manage this easy thing. The custom control inherits from...
    5. Exposing Font Name Property for Custom Control
      Hi, I've created a custom web control for using in my web application. I want to expose some Font-Name Properties of the control like i did for...
  3. #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

Posting Permissions

  • You may not post new threads
  • You may 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