Menu Horisontal

Minggu, 06 Januari 2013

Penomoran Pada DatagridView VB.Net

Sumber : http://class-super.blogspot.com/search/label/VB.Net
Cara menambahkan nomor pada DatagridView :



Kode Program VB.Net :
Private Sub DataGridViewRowPostPaint(sender As Object, e As DataGridViewRowPostPaintEventArgs)
 Dim dg As DataGridView = DirectCast(sender, DataGridView) 
 Dim rowNumber As String = (e.RowIndex + 1).ToString() 
 While rowNumber.Length < dg.RowCount.ToString().Length
  rowNumber = "0" & rowNumber
 End While
 
 Dim size As SizeF = e.Graphics.MeasureString(rowNumber, Me.Font)
 If dg.RowHeadersWidth < CInt(size.Width + 20) Then
  dg.RowHeadersWidth = CInt(size.Width + 20)
 End If
 
 Dim b As Brush = SystemBrushes.ControlText
 e.Graphics.DrawString(rowNumber, dg.Font, b, e.RowBounds.Location.X + 15, _
 e.RowBounds.Location.Y + ((e.RowBounds.Height - size.Height) / 2))
End Sub

1 komentar:

Aesel mengatakan...

Thank you atas scriptnya gan