download gratis video tutorial vb 6 dan vb.net plus contoh aplikasi

cara memformat data angka dalam datagridview

 

 

 


Imports System.Data.SqlClient

 

Public Class sqlserver2005

Dim conn As SqlConnection
Dim da As SqlDataAdapter
Dim ds As DataSet

 

Sub koneksi()
conn = New SqlConnection("data source=user-pc\sqlexpress;initial catalog=mydbagain;integrated security=true")
conn.Open()
End Sub


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call koneksi()
da = New SqlDataAdapter("select * from tblbarang", conn)
ds = New DataSet
da.Fill(ds)
DGV.DataSource = ds.Tables(0)
DGV.ReadOnly = True

DGV.Columns(3).DefaultCellStyle.Format = "#,###"
DGV.Columns("harga").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight

End Sub

End Class