Thread: OnPaint and dissappearing graphics

  1. #1
    essence of digital xddxogm3's Avatar
    Join Date
    Sep 2003

    OnPaint and dissappearing graphics

    I have created a program that has multiple panels, and created an array of graphic objects for these panels. I have background images on my panels that are drawn over during mouse click. In about 15 seconds after they are drawn over, the graphics disappear and the background image reappears. I implimented an onpain overide function, but it doesn't seem to stop this behavior. Does anyone know what i'm doing wrong?

            public static void RePaintPlayer(Graphics[] g)
                for (int x = 1; x <= 4; x++)
                    if (GS.Players[x].CurrentPosition != 0)
                        g[GS.Players[x].CurrentPosition].FillRectangle(new SolidBrush(Color.Blue), 0, 0, 50, 50);
                        g[GS.Players[x].CurrentPosition].DrawString("Player\n" + x, ArielFont, WhiteColor, new PointF(5, 10));
            protected override void OnPaint(PaintEventArgs e)
                for (int index = 1; index <= 64; index++)
    "Hence to fight and conquer in all your battles is not supreme excellence;
    supreme excellence consists in breaking the enemy's resistance without fighting."
    Art of War Sun Tzu

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Hannover, Germany
    If you have not done so already, consider setting the control styles to something more suited to painting yourself:

    If you do this, you may have to draw the background yourself.

    Also, I'd recommend to use a single control for painting. Do the calculations yourself and paint all of it in one control.

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

Popular pages Recent additions subscribe to a feed