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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:57:11+00:00 2026-05-14T08:57:11+00:00

Hoping for a quick answer (which SO seems to be pretty good for)… I

  • 0

Hoping for a quick answer (which SO seems to be pretty good for)…

I just ran a performance analysis with VS2010 on my app, and it turns out that I’m spending about 20% of my time in the Control.set_Text(string) function, as I’m updating labels in quite a few places in my app.

The window has a timer object (Forms timer, not Threading timer) that has a timer1_Tick callback, which updates one label every tick (to give a stop-watch sort of effect), and updates about 15 labels once each second.

Does anyone have quick suggestions for how to reduce the amount of time spent updating text on a form, other than increasing the update interval? Are there other structures or functions I should be using?

  • 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-14T08:57:11+00:00Added an answer on May 14, 2026 at 8:57 am

    I ran into this issue myself, and ended up creating my own simple Label control.

    .Net’s Label control is a surprisingly complicated beast, and is therefore slower than we’d like.

    You can make a class that inherits Control, call SetStyle in the constructor to make it double-buffered and user-painted, then override the OnPaint method to call e.Graphics.DrawString and draw the Text property.
    Finally, override Text or TextChanged and call Invalidate.

    As long as you don’t need AutoSize, this will be substantially faster than the standard Label control.

    Here is my implementation: (Currently in use in production)

    ///<summary>A simple but extremely fast control.</summary>
    ///<remarks>Believe it or not, a regular label isn't fast enough, even double-buffered.</remarks>
    class FastLabel : Control {
        public FastLabel() {
            SetStyle(ControlStyles.AllPaintingInWmPaint
                   | ControlStyles.CacheText
                   | ControlStyles.OptimizedDoubleBuffer
                   | ControlStyles.ResizeRedraw
                   | ControlStyles.UserPaint, true);
        }
        protected override void OnTextChanged(EventArgs e) { base.OnTextChanged(e); Invalidate(); }
        protected override void OnFontChanged(EventArgs e) { base.OnFontChanged(e); Invalidate(); }
    
        static readonly StringFormat format = new StringFormat {
            Alignment = StringAlignment.Center,
            LineAlignment = StringAlignment.Center
        };
        protected override void OnPaint(PaintEventArgs e) {
            e.Graphics.DrawString(Text, Font, SystemBrushes.ControlText, ClientRectangle, format);
        }
    }
    

    If you don’t want centering, you can get rid of, or change, the StringFormat.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am hoping that this will have a pretty quick and simple answer. I
I was hoping someone could answer my quick question as I am going nuts!
Hoping someone can provide an answer with this, although it's not 100% programming related.
Just a quick question: What are people's practices when you have to define the
I'll make this quick because I'm hoping to get it fixed as quickly as
I'm building what I am hoping to be a fairly simple, quick and dirty
Quick question about Ruby forking - I ran across a bit of forking code
We have a SQL Server 2005 database for which we want to improve performance
I'm hoping there's a way to avoid custom configuration files if an application runs
I'm hoping to find out what tools folks use to synchronize data between databases.

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.