Deskripsi
1. objek datagridview
objek ini digunakan untuk menampilkan data yang ingin digunkan pada objek grafik
2. objek grafik
menpilkan jumlah data yang ada dalam datagridview menjadi sebuah grafik
Pembuatan Form
1. buka Microsoft Visual Studio anda
2. bukalah file kumpulan latihan anda
3. pilih menu project lalu klik add windows form
4. drag objek dari toolbox anda. susun hingga menjadi form seperti form pada gambar dibawah ini.
5. masukkan script berikut
Public Class Latihan_44_46110008
Dim Jalan As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source =" & Application.StartupPath & "\Data grafik.ACCDB")
Dim gitik As New DataTable
Private Sub Latihan_44_46110008_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim kacci As New OleDb.OleDbDataAdapter
kacci = New OleDb.OleDbDataAdapter("select * from qpembelianperbulanan", Jalan)
gitik.Rows.Clear()
kacci.Fill(gitik)
kacci.Dispose()
dgv46110008.DataSource = gitik
chart46110008.RowCount = gitik.Rows.Count
chart46110008.ColumnCount = 3
'memasukkan data ke setiap baris dan setiap kolom dari tabel keuangan
Dim sekarang As Integer = 0
For Each kake As DataRow In gitik.Rows
sekarang = sekarang + 1
chart46110008.Row = sekarang
chart46110008.RowLabel = kake("Bulan")
chart46110008.Column = 1
chart46110008.Data = kake("Unit")
chart46110008.Column = 2
chart46110008.Data = kake("Rata-Rata Harga") / 10000
chart46110008.Column = 3
chart46110008.Data = kake("Jumlah") / 10000
Next
End Sub
Private Sub batang46110008_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles batang46110008.Click
chart46110008.chartType = MSChart20Lib.VtChChartType.VtChChartType2dBar
End Sub
Private Sub line46110008_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles line46110008.Click
chart46110008.chartType = MSChart20Lib.VtChChartType.VtChChartType2dLine
End Sub
Private Sub lingkar46110008_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lingkar46110008.Click
chart46110008.chartType = MSChart20Lib.VtChChartType.VtChChartType2dPie
End Sub
Private Sub batang2_46110008_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles batang2_46110008.Click
chart46110008.chartType = MSChart20Lib.VtChChartType.VtChChartType3dBar
End Sub
Private Sub line2_46110008_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles line2_46110008.Click
chart46110008.chartType = MSChart20Lib.VtChChartType.VtChChartType3dLine
End Sub
End Class
Tidak ada komentar:
Posting Komentar