Drawing.Color Problem

Discussion in 'ASP .Net Building Controls' started by Shawn B., Jul 26, 2003.

  1. Shawn B.

    Shawn B. Guest

    Greetings,

    In creating a server control I added a property of type
    System.Drawing.Color.

    When the control is rendered, it generates a style that contains a style
    called "backgroundColor" that will hold the value of
    [Property].ToKnownColor.

    It works well, except in some cases (if you set a system-defined color) such
    as the "Info" color. When it renders, it simply renders "Info" but in the
    style, that's not a known color. The MS controls render it as
    "InfoBackground" but I can't see where I get that name from. It appears
    that I have to know all these variations in the system-defined colors and
    replace them with the proper name. Is there an easier built-in way?


    Thanks,
    Shawn
    Shawn B., Jul 26, 2003
    #1
    1. Advertising

  2. Shawn B.

    saucer Guest

    try to use System.Drawing.ColorTranslator.ToHtml to convert the color for
    you or you can always do

    Color c = SystemColors.Info;
    string s = ColorTranslator.ToHtml(c);

    s = String.Format("#{0:x}{1:x}{2:x}", c.R, c.G, c.B);

    "Shawn B." <> wrote in message
    news:...
    > Greetings,
    >
    > In creating a server control I added a property of type
    > System.Drawing.Color.
    >
    > When the control is rendered, it generates a style that contains a style
    > called "backgroundColor" that will hold the value of
    > [Property].ToKnownColor.
    >
    > It works well, except in some cases (if you set a system-defined color)

    such
    > as the "Info" color. When it renders, it simply renders "Info" but in the
    > style, that's not a known color. The MS controls render it as
    > "InfoBackground" but I can't see where I get that name from. It appears
    > that I have to know all these variations in the system-defined colors and
    > replace them with the proper name. Is there an easier built-in way?
    >
    >
    > Thanks,
    > Shawn
    >
    >
    saucer, Jul 27, 2003
    #2
    1. Advertising

  3. Shawn B.

    Shawn B. Guest

    Hmm... that works. Thanks.

    Thanks,
    Shawn


    "saucer" <> wrote in message
    news:%...
    > try to use System.Drawing.ColorTranslator.ToHtml to convert the color for
    > you or you can always do
    >
    > Color c = SystemColors.Info;
    > string s = ColorTranslator.ToHtml(c);
    >
    > s = String.Format("#{0:x}{1:x}{2:x}", c.R, c.G, c.B);
    >
    > "Shawn B." <> wrote in message
    > news:...
    > > Greetings,
    > >
    > > In creating a server control I added a property of type
    > > System.Drawing.Color.
    > >
    > > When the control is rendered, it generates a style that contains a style
    > > called "backgroundColor" that will hold the value of
    > > [Property].ToKnownColor.
    > >
    > > It works well, except in some cases (if you set a system-defined color)

    > such
    > > as the "Info" color. When it renders, it simply renders "Info" but in

    the
    > > style, that's not a known color. The MS controls render it as
    > > "InfoBackground" but I can't see where I get that name from. It appears
    > > that I have to know all these variations in the system-defined colors

    and
    > > replace them with the proper name. Is there an easier built-in way?
    > >
    > >
    > > Thanks,
    > > Shawn
    > >
    > >

    >
    >
    Shawn B., Jul 27, 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. Sreejumon[MVP]

    convert hex to System.Drawing.Color

    Sreejumon[MVP], Jun 27, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    2,536
    Sreejumon[MVP]
    Jun 27, 2003
  2. PJ6
    Replies:
    4
    Views:
    4,865
  3. Replies:
    1
    Views:
    613
    Kevin Spencer
    Jan 9, 2006
  4. defn noob
    Replies:
    1
    Views:
    358
    Mark Space
    Jun 28, 2008
  5. Kamaljeet Saini
    Replies:
    0
    Views:
    364
    Kamaljeet Saini
    Feb 13, 2009
Loading...

Share This Page