Tuesday, February 22, 2011
Using Grid view in (vb.Net desktop application)
This case explained How to using DataGrid view. May be can help you to code in vb.Net using Data grid view.
Private Sub Formlihatgudang_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Classdatabase.ds.Clear() Classdatabase.bukadatabase() Classdatabase.perintahsql.CommandText = "select IDgudang,namagudang,kapasitas3 as kapasitasgudang from gudang" Classdatabase.da.SelectCommand = Classdatabase.perintahsql Classdatabase.da.Fill(Classdatabase.ds, "gudang") DataGridView1.DataSource = Classdatabase.ds DataGridView1.DataMember = "gudang" DataGridView1.ReadOnly = True Classdatabase.tutupdatabase() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim tanya As String tanya = MsgBox("Apakah anda ingin keluar?", MsgBoxStyle.YesNo, "Question") If tanya = vbYes Then Close() Else MsgBox("Silahkan Melanjutkan Penggunaan Aplikasi", MsgBoxStyle.Information, "Information") End If End Sub Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick Classdatabase.ds2.Clear() Classdatabase.bukadatabase() Classdatabase.perintahsql.CommandType = CommandType.Text Classdatabase.perintahsql.CommandText = "select lot.IDlot, lot.kapasitas2 as kapasitaslot from lot where lot.IDgudang ='" & DataGridView1.SelectedCells(0).Value & "'" Classdatabase.da.SelectCommand = Classdatabase.perintahsql Classdatabase.da.Fill(Classdatabase.ds2, "lot") DataGridView2.DataSource = Classdatabase.ds2 DataGridView2.DataMember = "lot" DataGridView2.ReadOnly = True Classdatabase.tutupdatabase() End Sub Private Sub DataGridView2_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView2.CellClick ref() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If ComboBox1.SelectedIndex = -1 Or TextBox1.Text = Nothing Then MsgBox("Parameter dan Nilai Harus Diisi", 48, "Informasi") Exit Sub End If Classdatabase.ds3.Clear() Classdatabase.bukadatabase() Classdatabase.perintahsql.CommandText = CommandType.Text Classdatabase.perintahsql.CommandText = "select masuk.Tanggal, masuk.namabarang,anggota.nama,anggota.perusahaan,anggota.kategori as member,anggota.HP from masuk inner join anggota on masuk.IDuser=anggota.IDuser where masuk.IDlot ='" & DataGridView2.SelectedCells(0).Value & "' and " & ComboBox1.Text & " like '%" & TextBox1.Text & "%'" Classdatabase.da.SelectCommand = Classdatabase.perintahsql Classdatabase.da.Fill(Classdatabase.ds3, "masuk") DataGridView3.DataSource = Classdatabase.ds3 DataGridView3.DataMember = "masuk" DataGridView3.ReadOnly = True Classdatabase.tutupdatabase() End Sub Public Sub ref() Classdatabase.ds3.Clear() Classdatabase.bukadatabase() Classdatabase.perintahsql.CommandType = CommandType.Text Classdatabase.perintahsql.CommandText = "select masuk.Tanggal, masuk.namabarang,anggota.nama,anggota.perusahaan,anggota.kategori as member,anggota.HP from masuk inner join anggota on masuk.IDuser=anggota.IDuser where masuk.IDlot ='" & DataGridView2.SelectedCells(0).Value & "' " Classdatabase.da.SelectCommand = Classdatabase.perintahsql Classdatabase.da.Fill(Classdatabase.ds3, "masuk") DataGridView3.DataSource = Classdatabase.ds3 DataGridView3.DataMember = "masuk" DataGridView3.ReadOnly = True Classdatabase.tutupdatabase() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click refresh() End Sub End Class |
This post was written by: Yung Fei
Follow me on My Twitter and like my Online Coupons fans page
- Best Regard -
OnlineCouponz
Fresh Printable Coupons
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment