Results 1 to 3 of 3

Thread: [RESOLVED] GDI+. Resize the form, does not refresh properly

Hybrid View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2008
    Location
    Jacksonville, Florida
    Posts
    147

    Resolved [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.
    vb.net and C# in 2008 .net 3.5
    ImaginaryDevelopment blog

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2008
    Location
    Jacksonville, Florida
    Posts
    147

    Re: GDI+. Resize the form, does not refresh properly

    Thanks invalidate worked
    vb.net and C# in 2008 .net 3.5
    ImaginaryDevelopment blog

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