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 8060871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:08:34+00:00 2026-06-05T10:08:34+00:00

Is it possible to apply a gradient to label text? Right now I am

  • 0

Is it possible to apply a gradient to label text?

Right now I am taking over a controls OnPaint and drawing the string of text that I want; however, this is to specific. I really want to make it so that the label itself gets applied the gradient colors I want. So in turn each character would have the gradient specified as the text has changed.

So instead of using the ForeColor I would apply a LinearGradientBrush. I am using WinForms at the moment.

EDIT 1

Here is the code that I am currently using. However, this only applies the gradient to all of the characters. I would like to change it so that each character in the string is applied.

// Draw the formatted text string to the DrawingContext of the control.
Font font = new Font("BankGothic Md BT", 48f, FontStyle.Bold);
LinearGradientBrush brush = new LinearGradientBrush(label1.Location, new Point(label1.Width, label1.Height), Color.Goldenrod, Color.Black);
e.Graphics.DrawString(label1.Text, font, brush, 0,0);

Edit 2

Here is what I did. I just extended the Label class and inherited OnPaint.

public partial class LabelEx : Label {
    public LabelEx() {
        InitializeComponent();
    }

    protected override void OnPaint(PaintEventArgs e) {
        // Draw the formatted text string to the DrawingContext of the control.
        //base.OnPaint(e);
        Font font = new Font("Tahoma", 48f, FontStyle.Bold);
        LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, Width, Height + 5), Color.Gold, Color.Black, LinearGradientMode.Vertical);
        e.Graphics.DrawString(Text, font, brush, 0, 0);

    }
}

Which gives me a nice gradient text label.

Thanks!

  • 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-06-05T10:08:36+00:00Added an answer on June 5, 2026 at 10:08 am

    Here is what I did. I just extended the Label class and inherited OnPaint.

    public partial class LabelEx : Label {
    
    public LabelEx() {
        InitializeComponent();
    }
    
    protected override void OnPaint(PaintEventArgs e) {
        // Draw the formatted text string to the DrawingContext of the control.
        //base.OnPaint(e);
        Font font = new Font("Tahoma", 48f, FontStyle.Bold);
        LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, Width, Height + 5), Color.Gold, Color.Black, LinearGradientMode.Vertical);
        e.Graphics.DrawString(Text, font, brush, 0, 0);
    
    }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to apply a css(3) style to a label of a checked
Is it possible to apply the Replication mechanism on single MySQL server? I want
Is it possible to apply HTTP header directives based on the URL's query string
Is it possible to apply an extension method to an interface? (C# question) That
Is it possible to apply shadow for header <h3> tags jquery.... alt text http://img541.imageshack.us/img541/9603/57972600.jpg
Is it possible to apply custom (added to the app) font to UILabel text
Is it possible to apply a dynamically created gradient mask on a textfield in
Is it possible to apply background-image and background-color to a text field at the
Is it possible to apply HTML code on highlighted text like in Zend Studio
Is it possible to apply a filter to the geometry data that is to

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.