3

I have a TabControl in which I add / remove several TabPages.

I get flickering issue when I add enough pages so that the navigation buttons have to be shown.

I have no flickering at all when the navigation buttons (2 arrows to navigate left - right) are not shown. The flicker is in no way related to resize of the form or pages being added.

I have tried:

  • DoubleBuffering
  • SetStyles(... all the params to increase performance)

EDIT: In my main WinForm, I added this code to prevent a rendering bug when resizing my window:

protected override CreateParams CreateParams 
{
    get
    {
        CreateParams cp = base.CreateParams;
        cp.ExStyle |= 0x02000000;
        return cp;
    }
}

When removed, I no longer get the flickering in my TabControl. It seems that I will have to live with the resizing rendering bug as it is more convenient that a constant flicker.

4
  • I assume you're overriding or piggybacking a Draw or Paint event somewhere...can we see that? Jun 4, 2013 at 19:14
  • The Draw and Paint events remain untouched. Jun 4, 2013 at 19:26
  • winforms == flicker. I don't think there's a way out of that.
    – Fede
    Jun 4, 2013 at 23:26
  • @HighCore: There are many ways out of it, the best one is to use WPF though.
    – Ray
    Aug 28, 2013 at 9:35

3 Answers 3

9

You left out an important detail. This question strongly suggests you did more than you described, you are also overriding the CreateParams property in your form to turn on the WS_EX_COMPOSITED style flag for the window. It enables double-buffering for the form and all of its controls, a good way to suppress flicker in general.

But it can have some detrimental side-effects. TabControl is in fact a trouble-maker, something messed up about the way it renders that is incompatible with WS_EX_COMPOSITED. Once too many tabs are added and the navigation buttons appear, it starts to constantly redraw itself. Perceived as rapid flicker. The native tab control renderer has lots of bugs, the Microsoft team that wrote it did a very lousy job.

There is no known workaround for this bug, you'll have to settle for a lesser alternative.

1
  • WS_EX_COMPOSITED is not a good solution for every case. I used it on form where there about 2 tabControls controling a total of 17 tabPages where there is about with 15 datagridviews and about 75 controls (textBoxes, comboboxes, radio, check, ...) and my CPU usage gone crazy to 100% of the CPU Core used by my application. Feb 4, 2014 at 19:13
1

Hi May be I am a bit late to answer, but I used this.Multiline = true; in my TabControl. This will allow TabControl to automatically adjust Tabs in multiline in case number of tabs goes more that available visual space.

You shall use this feature unless you have very specific requirement to keep all tabs in a single line.

0

The code above helped me resolved Tab flickering issue.I have two tabs in total (in one tab control).Tab names are being redrawn in a loop. The issue is more evident as form(window)'s area is increased.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.