Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7515319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:46:15+00:00 2026-05-30T00:46:15+00:00

so right now I need to make a custom control for a c# project,

  • 0

so right now I need to make a custom control for a c# project, The main point is I would like to make one control where i can change the text-color using the control properties via a drop-down. So I would like to limit what colors can be choosen. Right now, i have Four separate color labels,, but I need one with an option to change the color from a single property. The colors are predefined using RGB values. Here is the existing label code, how can I make it into one label with multiple color options?

That is the existing label code.
http://pastebin.com/mezTBMxN
Thank you for all help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T00:46:17+00:00Added an answer on May 30, 2026 at 12:46 am

    You can define your own custom property using a public enum containing the four colors you want. Then, when you render your control, you can set the ForeColor accordingly.

    Enum:

    public enum LabelColor
    {
        Gray,
        Green,
        Blue,
        Red,
        None
    }
    

    Custom Property:

    [Bindable(true)]
    [DefaultValue(LabelColor.None)]
    [Category("Appearance")]
    public LabelColor TextColor
    {
        get
        {
            EnsureChildControls();
            return (ViewState["TextColor"] != null) ?
                (LabelColor)Enum.Parse(typeof(LabelColor), ViewState["TextColor"].ToString()) :
                LabelColor.None;
        }
    
        set
        {
            EnsureChildControls();
            ViewState["TextColor"] = value;
        }
    }
    

    Set color in constructor or override RenderControl(). Note, you can use Color.FromArgb() if you like, however, I would recommend assigning CSS classes to keep your presentation separated.

    switch (this.TextColor)
    {
        case LabelColor.Gray:
            this.CssClass = "label-gray";
            break;
        case LabelColor.Blue:
            this.CssClass = "label-blue";
            break;
        case LabelColor.Green:
            this.CssClass = "label-green";
            break;
        case LabelColor.Red:
            this.CssClass = "label-red";
            break;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a project right now in which I need to automate animated
In a current project i need to display PDFs in a webpage. Right now
For a project I'm working on, I need to make a custom button that
Ok I promise I'll learn regular expressions tonight but right now I need a
I need some help. Here's what I'm getting right now: img ref I need
I have id values for products that I need store. Right now they are
Right now my ant task looks like. <javadoc sourcepath=${source} destdir=${doc}> <link href=http://java.sun.com/j2se/1.5.0/docs/api/ /> </javadoc>
Right now I'm doing something like this: RewriteRule ^/?logout(/)?$ logout.php RewriteRule ^/?config(/)?$ config.php I
Right now in Spring security I have this code: <session-management> <concurrency-control max-sessions=1 error-if-maximum-exceeded=true />
So right now i need to create and implement an extension of the Python

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.