Results 1 to 6 of 6

Thread: DefaultValue

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2005
    Location
    Cebu
    Posts
    607

    Resolved DefaultValue

    What's wrong with
    Code:
            Color color1;
            [DefaultValue(Color.LightBlue)]
            public Color GradientColor1
            {
                get{ return color1;}
                set{ color1=value;}
            }
    ?

    This gives me F:\My Project\c#\nebzie\swing\NPanel.cs(27): An attribute argument must be a constant expression, typeof expression or array creation expression.
    Last edited by nebulom; Feb 10th, 2005 at 04:57 AM.

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Try it this way :
    Code:
    private Color color1; 
    [DefaultValue(typeof(Color),"LightBlue")] 
    public Color GradientColor1 
    {
    get{ return color1;} 
    set{ color1=value;}
    }
    

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2005
    Location
    Cebu
    Posts
    607

    Re: DefaultValue

    A million of Thanks.

    nebzie

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2005
    Location
    Cebu
    Posts
    607

    Re: DefaultValue

    Pirate,

    Hello. It still doesn't got to the property Window. I mean, i'm writing a custom panel and when I add it on the toolbox and drag it, GradientColor1 property still has no default value. Am I missing something?

    Thank you.

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    You wouldn't need it then , just do like and initialize the variable with the color you want the control to be set to :

    Code:
     private Color color1=Color.LightBlue; 
    
    public Color GradientColor1 
    {
    get{ return color1;} 
    set{ color1=value;}
    }
    

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2005
    Location
    Cebu
    Posts
    607

    Re: DefaultValue

    Oh. Miss that one. Thanks Pirate.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width