Exposing Font Name Property for Custom Control

Discussion in 'ASP .Net Building Controls' started by Deep S., Aug 4, 2003.

  1. Deep S.

    Deep S. Guest

    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 the Color and Boolean values, so that in the properties
    pane, a proper list is displayed for user selection.
    Like for picking up the color i've declared a property with data type
    as System.Drawing.Color. This shows the Color Picker in the
    Property Window.
    For Font Name Picker with which data type should i declare the
    property with ??

    Thanks for your help in advance.
    Regards
    Deep S.
     
    Deep S., Aug 4, 2003
    #1
    1. Advertising

  2. Hi You should use FontInfo, see the sourcecode below :


    [
    Category("TextBox"),
    Description("Font of the textbox.")
    ]
    public FontInfo TextBoxFont
    {
    get
    {
    object savedState = this.ViewState["TextBoxFont"];
    if ( savedState == null )
    {
    return myTextBox.Font;
    }
    return (FontInfo)savedState;
    }
    set
    {
    myTextBox.Font.CopyFrom(value);
    this.ViewState["TextBoxFont"] = value;
    }
    }





    >-----Original Message-----
    >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 the Color and Boolean values, so that

    in the properties
    > pane, a proper list is displayed for user selection.
    > Like for picking up the color i've declared a property

    with data type
    > as System.Drawing.Color. This shows the Color Picker

    in the
    > Property Window.
    > For Font Name Picker with which data type should i

    declare the
    > property with ??
    >
    >Thanks for your help in advance.
    >Regards
    >Deep S.
    >
    >
    >.
    >
     
    Karsten Lundsgaard, Aug 4, 2003
    #2
    1. Advertising

  3. Deep S.

    Deep S. Guest

    Hi Karsten,
    Thanks for your reply, but i tried something like this by figuring out
    the approach to be taken in my code.
    But the property that is coming at the design time for the control
    is coming with just one text box. I want to make it something
    like we get when we edit the font properties for any other
    control like textbox etc through which the user can select
    Font Name, Bold, Italic etc properties for my control.

    Dim _sysItemFontInfo As System.Web.UI.WebControls.FontInfo

    <Bindable(True), Description("Font properties of the list items."),
    Category ("ListOptions"), DefaultValue("")> Property [ItemFont]() As
    System.Web.UI.WebControls.FontInfo
    Get
    Return _sysItemFontInfo
    End Get
    Set(ByVal Value As System.Web.UI.WebControls.FontInfo)
    _sysItemFontInfo = Value
    End Set
    End Property

    Maybe there is some problem with my code. But i got no sample/
    help related to this issue on MSDN as well as some other sites i know.
    Is there anything else i need to do apart from this code?

    Thanks for your reply.

    Regards
    Deep S.
     
    Deep S., Aug 4, 2003
    #3
    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. Paul
    Replies:
    1
    Views:
    427
  3. mttc
    Replies:
    2
    Views:
    2,402
    Roedy Green
    Jul 3, 2009
  4. Exposing an event handler as a control property

    , Aug 28, 2006, in forum: ASP .Net Building Controls
    Replies:
    3
    Views:
    167
    studen771
    Sep 30, 2006
  5. Replies:
    0
    Views:
    138
Loading...

Share This Page