Properties of Properties

Discussion in 'ASP .Net' started by Nathan Sokalski, Oct 27, 2008.

  1. I have a System.Web.UI.Control which has a property of type
    System.Drawing.Font. When editing this control in an *.aspx file, how do I
    assign a value to this property? If I recall correctly, the attributes in
    the server tag are a combination of the property name and the property of
    that property separated by a "-" or something. However, I would also like to
    be able to use the Property Grid to do this. I tried using the Browsable
    attribute for the property, but that did not seem to help. Here is my
    current code for the property:

    <System.ComponentModel.Browsable(True)> WriteOnly Property Font() As
    Set(ByVal value As System.Drawing.Font)
    Me._font = value
    End Set
    End Property

    Am I forgetting something? Any help would be appreciated. Thanks.
    Nathan Sokalski, Oct 27, 2008
    1. Advertisements

  2. Nathan Sokalski

    bruce barker Guest

    in general the property designer only support simple types by default
    (string, numbers, enum). while the designer knows about color and size,
    window fonts are not included. you will need to write your own prop designer
    to support them. in the syntax, all properties must be able to be
    specified as a string.

    as fonts are specified to the browser via a style command, not sure why you
    do not just support a style and class (CSSClass) properties.

    -- bruce (
    bruce barker, Oct 27, 2008
    1. Advertisements

  3. My reason for not using a style and class is because the control will be
    generating an image, and therefore needs a System.Drawing.Font object.
    Assuming you are correct in your statements, I will probably need to just
    make separate properties and use the System.Drawing.Font constructor to
    create the font. I was just hoping to not need to make separate properties,
    but I guess that's all I can do for now since I don't know how to make
    Property Designers yet (and there probably wouldn't be much point in this
    case, since I only have one control that would need it). Thanks.
    Nathan Sokalski, Oct 27, 2008
  4. You should be able to work with this property in the property grid. The
    System.Drawing.Font type has an associated editor, which the property grid
    should expose to you.

    What happens in the property grid?
    John Saunders, Oct 27, 2008
  5. All the Property Grid shows is the name of the property and a place to enter
    a value. It shows up the same way a property of type String or Integer or
    would. Is there an Property Attribute I need to add to make the associated
    editor available? Thanks.
    Nathan Sokalski, Oct 27, 2008
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.