Results 1 to 3 of 3

Thread: [2.0] Updating a specific part of my window (in the paint event)

  1. #1

    Thread Starter
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    [2.0] Updating a specific part of my window (in the paint event)

    Code:
            private void Form1_Paint(object sender, PaintEventArgs e)
            {
    			for (int i = 0; i < currentGrid.GetUpperBound(0); i++)
    			{
    				for (int k = 0; k < currentGrid.GetUpperBound(1); k++)
    				{
    					Bitmap bmp = new Bitmap(images[currentGrid[i, k]]);
    					e.Graphics.DrawImage(bmp, new Point(k * gridWidth, i * gridHeight));
    					bmp.Dispose();
    					bmp = null;
    				}
    			}	
    			HighlightTile(e);
    		}
    when I click, it updates the position that my highlighted tile is at, however I have to call this.Refresh();, and it lags because I am drawing the whole thing again, any way I can refresh 'only' a part of it?

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [2.0] Updating a specific part of my window (in the paint event)

    tried something like this?
    C# Code:
    1. Me.Invalidate (New Rectangle(0,0,100,100));

    Just specify a region to be repainted using either a Rectangle or a Region.
    http://msdn2.microsoft.com/en-us/lib...te(VS.80).aspx
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3

    Thread Starter
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    Re: [2.0] Updating a specific part of my window (in the paint event)

    Thanks vm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width