![]() |
GDI+ Examples: Column Chart |
|
![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Public Class Form1
Inherits System.Windows.Forms.Form
Dim graphDrawingArea As Graphics
Dim bmpDrawingArea As Bitmap
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
bmpDrawingArea = New Bitmap(Width, Height)
graphDrawingArea = Graphics.FromImage(bmpDrawingArea)
End Sub
End Class
|
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
e.Graphics.DrawImage(bmpDrawingArea, 0, 0)
End Sub
|
Private Sub btnGenerate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGenerate.Click
Dim monday As Integer = CInt(Me.txtMonday.Text) / 100
Dim tuesday As Integer = CInt(Me.txtTuesday.Text) / 100
Dim wednesday As Integer = CInt(Me.txtWednesday.Text) / 100
Dim thursday As Integer = CInt(Me.txtThursday.Text) / 100
Dim friday As Integer = CInt(Me.txtFriday.Text) / 100
graphDrawingArea.Clear(Me.BackColor)
graphDrawingArea.DrawRectangle(New Pen(Color.Red), Me.txtMonday.Left + 5, 280 - monday, 40, monday)
graphDrawingArea.DrawRectangle(New Pen(Color.Blue), Me.txtTuesday.Left + 5, 280 - tuesday, 40, tuesday)
graphDrawingArea.DrawRectangle(New Pen(Color.Fuchsia), Me.txtWednesday.Left + 5, 280 - wednesday, 40, wednesday)
graphDrawingArea.DrawRectangle(New Pen(Color.Brown), Me.txtThursday.Left + 5, 280 - thursday, 40, thursday)
graphDrawingArea.DrawRectangle(New Pen(Color.Turquoise), Me.txtFriday.Left + 5, 280 - friday, 40, friday)
graphDrawingArea.DrawRectangle(New Pen(Color.Black), 10, 280, Width - 30, 1)
Invalidate()
End Sub
|

Private Sub btnGenerate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGenerate.Click
Dim monday As Integer = CInt(Me.txtMonday.Text) / 100
Dim tuesday As Integer = CInt(Me.txtTuesday.Text) / 100
Dim wednesday As Integer = CInt(Me.txtWednesday.Text) / 100
Dim thursday As Integer = CInt(Me.txtThursday.Text) / 100
Dim friday As Integer = CInt(Me.txtFriday.Text) / 100
graphDrawingArea.Clear(Me.BackColor)
graphDrawingArea.FillRectangle(New SolidBrush(Color.Red), Me.txtMonday.Left + 5, 280 - monday, 40, monday)
graphDrawingArea.DrawRectangle(New Pen(Color.Black), Me.txtMonday.Left + 5, 280 - monday, 40, monday)
graphDrawingArea.FillRectangle(New SolidBrush(Color.Blue), Me.txtTuesday.Left + 5, 280 - tuesday, 40, tuesday)
graphDrawingArea.DrawRectangle(New Pen(Color.Black), Me.txtTuesday.Left + 5, 280 - tuesday, 40, tuesday)
graphDrawingArea.FillRectangle(New SolidBrush(Color.Fuchsia), Me.txtWednesday.Left + 5, 280 - wednesday, 40, wednesday)
graphDrawingArea.DrawRectangle(New Pen(Color.Black), Me.txtWednesday.Left + 5, 280 - wednesday, 40, wednesday)
graphDrawingArea.FillRectangle(New SolidBrush(Color.Brown), Me.txtThursday.Left + 5, 280 - thursday, 40, thursday)
graphDrawingArea.DrawRectangle(New Pen(Color.Black), Me.txtThursday.Left + 5, 280 - thursday, 40, thursday)
graphDrawingArea.FillRectangle(New SolidBrush(Color.Turquoise), Me.txtFriday.Left + 5, 280 - friday, 40, friday)
graphDrawingArea.DrawRectangle(New Pen(Color.Black), Me.txtFriday.Left + 5, 280 - friday, 40, friday)
graphDrawingArea.DrawRectangle(New Pen(Color.Black), 10, 280, Width - 30, 1)
Invalidate()
End Sub
|

|
|
||
| Home | Copyright © 2004-2010 FunctionX, Inc. | |
|
|
||