combo lookup textbox vbnet msaccess
Jumat, 11 Maret 2016
Edit
Dalam pembuatan aplikasi seringkali ANDA dihadapkan pada masalah pemilihan kode barang dari combo barang lalu menampilkan nama barang nya di textbox seperti gambar di bawah ini: |
selanjutnya setelah dipilih salah satu item barang lalu di klik combo nya maka nama barang muncul di textbox seperti gambar di bawah ini: |
berikut adalah kode sellengkapnya: |
Imports System.Data.OleDb
Public Class Form1
Private sConn As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & _
Application.StartupPath & _
"\database1.accdb;Persist Security Info=False;"
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
isiCombo()
End Sub
Private Sub isiCombo()
Dim oConn As New OleDbConnection(sConn)
oConn.Open()
Dim oCmd As New OleDbCommand("select nama_barang from tblBarang", oConn)
Dim oDr As OleDbDataReader
oDr = oCmd.ExecuteReader
Dim oTbl As New DataTable
oTbl.Load(oDr)
For i = 0 To oTbl.Rows.Count - 1
ComboBox1.Items.Add(oTbl.Rows(i).Item(0))
Next
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal _
e As System.EventArgs)Handles ComboBox1.SelectedIndexChanged
TextBox1.Text = ComboBox1.Text
End Sub
End Class
|
download source code combo lookup texbot vbnet ms access klik di sini! |