Color Property DefaultValue

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • timtos

    #1

    Color Property DefaultValue

    I want to set a color property of a user control by default.
    I am doing it like this:

    ....
    DefaultValue(ty peof(System.Dra wing.Color), "Blue"),
    ....

    The compiler likes it but my program ignores it!
    I´ve also tried other things like:

    DefaultValue(ty peof(Color), "Blue"),
    DefaultValue(ty peof(Color), "Color.Blue "),
    DefaultValue(ty peof(System.Dra wing.Color), "0, 0, 255"),
    DefaultValue(ty peof(System.Dra wing.Color), "0; 0; 255"),

    Searching the net I found a lot of solutions like the ones above.
    But the problem is none of them are working for me.

    Any ideas?
    Thanks,
    timtos.


  • Jay B. Harlow [MVP - Outlook]

    #2
    Re: Color Property DefaultValue

    Timtos,
    The DefaultValue attribute tells the designer what the constructor of your
    object considers the default value. You still need to set the default for
    the backing field on the property to the default, I normally do this in the
    constructor.

    I normally use:[color=blue]
    > DefaultValue(ty peof(System.Dra wing.Color), "Blue"),[/color]

    Hope this helps
    Jay

    In the constructor of your
    "timtos" <tirobu@gmx.d e> wrote in message
    news:bij665$2p0 d$1@news.uni-koblenz.de...[color=blue]
    > I want to set a color property of a user control by default.
    > I am doing it like this:
    >
    > ...
    > DefaultValue(ty peof(System.Dra wing.Color), "Blue"),
    > ...
    >
    > The compiler likes it but my program ignores it!
    > I´ve also tried other things like:
    >
    > DefaultValue(ty peof(Color), "Blue"),
    > DefaultValue(ty peof(Color), "Color.Blue "),
    > DefaultValue(ty peof(System.Dra wing.Color), "0, 0, 255"),
    > DefaultValue(ty peof(System.Dra wing.Color), "0; 0; 255"),
    >
    > Searching the net I found a lot of solutions like the ones above.
    > But the problem is none of them are working for me.
    >
    > Any ideas?
    > Thanks,
    > timtos.
    >
    >[/color]


    Comment

    • timtos

      #3
      Re: Color Property DefaultValue

      Thanks for making things clear!
      It is "working" now ;-)

      Greetings,
      timtos.

      "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> wrote in message news:um0$6$NbDH A.2436@TK2MSFTN GP12.phx.gbl...[color=blue]
      > Timtos,
      > The DefaultValue attribute tells the designer what the constructor of your
      > object considers the default value. You still need to set the default for
      > the backing field on the property to the default, I normally do this in the
      > constructor.
      >
      > I normally use:[color=green]
      > > DefaultValue(ty peof(System.Dra wing.Color), "Blue"),[/color]
      >
      > Hope this helps
      > Jay
      >
      > In the constructor of your
      > "timtos" <tirobu@gmx.d e> wrote in message
      > news:bij665$2p0 d$1@news.uni-koblenz.de...[color=green]
      > > I want to set a color property of a user control by default.
      > > I am doing it like this:
      > >
      > > ...
      > > DefaultValue(ty peof(System.Dra wing.Color), "Blue"),
      > > ...
      > >
      > > The compiler likes it but my program ignores it!
      > > I´ve also tried other things like:
      > >
      > > DefaultValue(ty peof(Color), "Blue"),
      > > DefaultValue(ty peof(Color), "Color.Blue "),
      > > DefaultValue(ty peof(System.Dra wing.Color), "0, 0, 255"),
      > > DefaultValue(ty peof(System.Dra wing.Color), "0; 0; 255"),
      > >
      > > Searching the net I found a lot of solutions like the ones above.
      > > But the problem is none of them are working for me.
      > >
      > > Any ideas?
      > > Thanks,
      > > timtos.
      > >
      > >[/color]
      >
      >[/color]


      Comment

      Working...