0% found this document useful (0 votes)
18 views2 pages

Car I Data Dari Combo Box

This document describes the design of a form that displays data from a database table in a datagrid and allows the user to filter the datagrid by selecting an item from a combobox. The form loads data from the "TblBarang" table into the datagrid and populates the combobox with codes from the table. When an item is selected from the combobox, the datagrid is filtered to only display records matching the selected code.

Uploaded by

apryfoe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views2 pages

Car I Data Dari Combo Box

This document describes the design of a form that displays data from a database table in a datagrid and allows the user to filter the datagrid by selecting an item from a combobox. The form loads data from the "TblBarang" table into the datagrid and populates the combobox with codes from the table. When an item is selected from the combobox, the datagrid is filtered to only display records matching the selected code.

Uploaded by

apryfoe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

C.

CARI DATA DARI COMBOBOX


Desain form berikut:

Imports Microsoft.VisualBasic
Imports System.Data.OleDb
Public Class CariDataDariComboBox
Sub tampilkan_DataPadaGrid()
da = New OleDbDataAdapter("select * from TblBarang", conn)
ds = New DataSet
ds.Clear()
da.Fill(ds, "TblBarang")
DataGridView1.DataSource = (ds.Tables("TblBarang"))
DataGridView1.Columns(0).Width = 77
DataGridView1.Columns(1).Width = 150
End Sub
Sub tampilDatacOMBO()
Cmd = New OleDbCommand("select * from TblBarang ", conn)
dr = Cmd.ExecuteReader
Do While dr.Read()
ComboBox1.Items.Add(dr.Item(0))
Loop
End Sub
Private Sub TampilDataPadaGrid_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Call KoneksiDB()
Call tampilkan_DataPadaGrid()
End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal


e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
da = New OleDbDataAdapter("select * from TblBarang where Kode_Barang = " & _
" '" & Trim(ComboBox1.Text) & "' ", conn)
ds = New DataSet
ds.Clear()
da.Fill(ds, "TblBarang")
DataGridView1.DataSource = (ds.Tables("TblBarang"))
End Sub
End Class

You might also like