'Start Menampilkan data pada Datagrid View
Dim cmd As OleDbCommand = New OleDbCommand("Select * from T_Titles", myconnection.open)
cmd.CommandType = CommandType.Text
Dim adapter As OleDbDataAdapter = New OleDbDataAdapter(cmd)
Dim datatbl As DataTable = New DataTable
Dim ds As DataSet = New DataSet()
' Mengambil info column (Read-only).
adapter.FillSchema(ds, SchemaType.Mapped, "Titles")
' Isi table
adapter.Fill(ds, "Titles")
datatbl = ds.Tables("Titles")
myconnection.close()
DataGridView1.DataSource = datatbl
'Finish Menampilkan data pada Datagrid View
'Menghapus auto generate Authors Colomn
DataGridView1.Columns.Remove("Authors")
'Membuat List columns untuk Authors field
Dim listCol As DataGridViewComboBoxColumn = New DataGridViewComboBoxColumn()
'Posisi column nomor 2
listCol.DisplayIndex = 1
'Nama Header= "Authors"
listCol.HeaderText = "Authors"
'Masukkan nama field pada table yang akan di buat listcolom
listCol.DataPropertyName = "Authors"
'Mengisi list dari T_Titles table
listCol.DataSource = ds.Tables("Titles")
listCol.DisplayMember = "Authors"
listCol.ValueMember = "Authors"
'Tambahkan column
DataGridView1.Columns.Add(listCol)
Tidak ada komentar:
Posting Komentar