Very slow rendering of tabs

R

rubyhcurry

Hello,

I have a small application which acts like a wizard with 5 steps. I
use a tab control, and 'back' and 'next' buttons to switch between the
5 tabs (1 tab page for each step). The components on each tab are very
light (mostly labels and input fields) and my C# code (the actual
program logic) is well optimized. I also use multi threading to
separate the UI from the core of the app.

The rendering of the each tab page when I click 'next' is unacceptably
slow even on a very fast machine. Each time a new tab page becomes
active, the screen flickers a lot in the transition and it takes a few
moments (my guess is half a second). Clicking on the tab page
directly, instead of using a button, doesn't affect the speed.

Is there a way to speed up this thing or are Windows Forms used this
way bound to be very slow? All I need is a responsive UI. Is there an
easy way to preload them or pre-paint the pages at load time? It looks
like the repaint when a tab page becomes active, is what takes most of
the execution time.

Thank you.
-- Ruby
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

You will have to post some code to see how you are creating your tabs.
You are not creating the controls when you show the tab are you?
 
R

rubyhcurry

Hi,

You will have to post some code to see how you are creating your tabs.
You are not creating the controls when you show the tab are you?

Hi Ignacio,

the controls are all created at design time. The only thing that
happens at run time is the addition of the page and the selection of
the active tab. When one clicks on 'next' the code invoked is the
following:

private void OpenNext()
{
TabPage currentOne = mainTab.SelectedTab;
switch (current.Text)
{
case "Step A":
if (!mainTab.TabPages.Contains(PageB))
mainTab.TabPages.Add(PageB);
mainTab.SelectedTab = PageB;
break;
case "Step B":
if (!mainTab.TabPages.Contains(PageC))
mainTab.TabPages.Add(PageC);
mainTab.SelectedTab = PageC;
break;
//...
}
}

I tried to select a tab that was already added and it doesn't change
the speed.

Further investigation shows that this flickering effect is no longer
there and the pages load instantly if I remove the background image
that is loaded for each tab. Is there a way to have it loaded very
fast?

Thanks.
-- Ruby
 
J

Johnny J.

Could it be that your background picture is of much higher resolution than
needed? Try lowering the resolution to see how it affects speed and look...

Cheers,
Johnny J.
 
C

Chris Shepherd

Further investigation shows that this flickering effect is no longer
there and the pages load instantly if I remove the background image
that is loaded for each tab. Is there a way to have it loaded very
fast?

I've notice the flickering effect issue on several .NET apps when using
customized backgrounds. It doesn't take kindly to redraws for whatever
reason.

What type of image are you using as the background? Are they JPEGs, or
BMP/PNG? The former tends to load a lot faster and have smaller file
sizes (hence its proliferation on the Internet), while the latter are
non-lossy formats, meaning all of the original image data will remain.

Chris.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top