Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

I am manualy drawing 2 graphs on a picturebox. I put the drawing code in a routine and call it front the _Paint() event.

 

The problem is:

When the form is first loaded its invisible, and when I move the form from halfway off the screen, it won't repaint fully.

 

So basicaly I need a way to make this picturebox repaint no matter what happens

 

Here is the relavent code:

 

======== Form Load =========

Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
                               Call MakeGraph()
	Me.SetStyle(ControlStyles.ResizeRedraw, True)
	Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or ControlStyles.DoubleBuffer, True)
End Sub

======== Control Paint =========

Private Sub picGraph_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles picGraph.Paint
	Call MakeGraph()
End Sub

 

Also to note, it works with other controls, just doesn't seem to want to go with picturebox

Edited by Algar
  • *Experts*
Posted

Im not excatly sure what you need but since you said you need to force repaint try this:

PictureBox1.Invalidate()

This will make the pic box repaint when you call this. You could call this in your form's move event.

Posted

Ok, thanks a lot, works great !

 

I had already figured out that regraphing on the move event worked, but your way is much less resource intensive

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...