How to Create buttons runtime but is very slow

Our application was designed in VS2003, but now upgrade our application to VS2008
When this button is created, this redraw very time.
our application is food services contain in Tab Control
like    [ Food ] [  Desserts ] [ BarMenu ]
[Food1][Food2]      [Dessert1][Dessert2]      [Beer1][Beer2] ..etc
..etc                       etc...                                etc..
when the user change el tab index, all bottons redraw very time, every menu (tab) have 4x7 buttons;
our users say this very slow that previous version ( vs2003 )
we try  DoubleBuffered = True;

Do you have any answer for that...

MarvinBrenesAsked:
Who is Participating?
 
Sarika30Connect With a Mentor Commented:

Make sure your backgroundcolor is not set to 'transparent'. Set to 'white' for better performance.

Also, do backgroundimagelayout to be either 'center' or 'streach' to increase performance. This will enable the double buffer on the form

0
 
muckeypuckConnect With a Mentor Commented:
There's also a way to clip and render certain parts. So for example if only 1 button changed theres a clipping property(i think this is it but im totally going off the top of my head)  that lets you update just the parts that changed.

Yea it is clipping.

see: http://msdn.microsoft.com/en-us/library/79eytxt5.aspx
0
 
srllemoConnect With a Mentor Commented:
you can try with this :

    public static class DoubleBufferedControl
    {
        public static void Set(Control c)
        {
            // To avoid flickering in case of remote sessions like remote desktop avoid double buffering
            //In case of local session turn on double buffering
            // Doublebuffered is property of  Control class so we use Reflection

            if (SystemInformation.TerminalServerSession)
                return;

            System.Reflection.PropertyInfo aProp =
                  typeof(System.Windows.Forms.Control).GetProperty(
                        "DoubleBuffered",
                        System.Reflection.BindingFlags.NonPublic |
                        System.Reflection.BindingFlags.Instance);

            aProp.SetValue(c, true, null);
        }
    }

Usage:

in your code after creating button try call static method set of given class:

DoubleBufferedControl.Set(button);
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.