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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:00:30+00:00 2026-05-22T19:00:30+00:00

I have a user control with custom painting. Constructor sets styles correctly, from what

  • 0

I have a user control with custom painting. Constructor sets styles correctly, from what I can tell. Basic code:

public partial class LineChart2 : UserControl
{
    public LineChart2()
    {
        InitializeComponent();

        //Set control styles to eliminate flicker on redraw and to redraw on resize
        this.SetStyle(
            ControlStyles.ResizeRedraw |
            ControlStyles.UserPaint |
            ControlStyles.AllPaintingInWmPaint |
            ControlStyles.DoubleBuffer,
            true);

        SetDefaultValues();
    }

    protected override void OnPaint(PaintEventArgs e)
    {
    // breakpoint set here for verification
        Paint~misc stuff(e.Graphics);

        base.OnPaint(e);
    }

    private void UpdateGraph()
    {
    // this is called when the data that the control depends on changes
        ~update stuff();

        this.Invalidate();
        //this.Refresh();
    }
}

The control is contained within a Panel on a standard WinForm.

I’ve tried both Invalidate and Refresh.

When using Invalidate(), the control will redraw properly as long as the form it is contained in has focus. Drawing is smooth. When I switch focus to another form, drawing ceases even though the events are still firing, and this.Invalidate() is still being called. The form is still fully visible on screen.

When using Refresh(), the control will redraw regardless of whether the form has focus, but the drawing constantly flickers, as if bypassing the double-buffering mechanism.

So how do I get the Invalidate message to properly invoke the OnPaint method regardless of focus?

  • 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-22T19:00:31+00:00Added an answer on May 22, 2026 at 7:00 pm

    Documentation says:

    Calling the Invalidate method does not
    force a synchronous paint; to force a
    synchronous paint, call the Update
    method after calling the Invalidate
    method.

    Have you tried calling Update after Invalidate?

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

Sidebar

Related Questions

I have a custom control called TextBoxWithLabelAndUnits . From the name, you can tell
I have a custom WinForms control (inherits from control, i.e. without user interface jsut
I have a custom user control UserProfileLink on which I have two basic string
I have a custom user control DatePicker.cs. Inside of another piece of code I
I have a custom user control that contains asp:ValidationSummary . It is placed on
I have a custom user control with a textbox on it and I'd like
I have a custom user control on my windows forms. This control has a
I have a custom user control called ErrorNotificationBox. To place that on my page
I have a WinForms user control Host with a custom UI Editor. Through that
I have a custom base user control in silverlight. <UserControl x:Class=Problemo.MyBaseControl xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:d=http://schemas.microsoft.com/expression/blend/2008

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.