-
Apr 22nd, 2009, 12:17 PM
#1
Thread Starter
Addicted Member
[RESOLVED] GDI+. Resize the form, does not refresh properly
I'm trying to figure out how to make a dynamically scaling/resizing 2d chart on a form as my 1st trip into graphics. Most 3rd party addons/DLLs are of no use to me as the bank I work for is unlikely to allow any of those to be used in my projects.
I want the chart to stay at the bottom of the form no matter if it's sized larger or smaller. It's not working properly on shrink or grow of the form.
Code:
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Const width As Integer = 10
Dim heights() As Integer = {10, 0, 30, 60}
Dim bottom As Integer = CInt(e.Graphics.VisibleClipBounds.Bottom)
For index As Integer = 0 To heights.Length - 1
e.Graphics.DrawRectangle(Pens.Black, New Rectangle(index * width _
, bottom - heights(index) - 1, width, bottom))
Next
End Sub
Also I have no idea how to use the vbCode button on these forums it asks for a highlight option.
-
Apr 22nd, 2009, 02:16 PM
#2
Re: GDI+. Resize the form, does not refresh properly
Try adding this code
Code:
Private Sub Form1_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
Me.Invalidate()
End Sub
As a side note, you could think of possibly using labels to make your graph, as a 2D bar graph is generally pretty easy to lay out using labels and their anchor properties (you could get nice auto sizing going) or even look at the MSChart control, since it is not technically 3rd party (although it is COM active X)
http://msdn.microsoft.com/en-us/libr...24(VS.71).aspx
PS I hate the vbcode tags because from IE you can't copy/paste into VS easily. I always use the code tags
-
Apr 22nd, 2009, 02:46 PM
#3
Thread Starter
Addicted Member
Re: GDI+. Resize the form, does not refresh properly
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|