Add Rows Number to DataGridView
Tháng Chín 12, 2008 at 1:04 sáng Để lại phản hồi
Private Sub ExDataGrid1_CellPainting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellPaintingEventArgs) Handles ExDataGrid1.CellPainting
Dim sf As New StringFormat
sf.Alignment = StringAlignment.Center
If e.ColumnIndex < 0 AndAlso e.RowIndex >= 0 AndAlso e.RowIndex < ExDataGrid1.Rows.Count – 1 Then
e.PaintBackground(e.ClipBounds, True)
e.Graphics.DrawString((e.RowIndex + 1).ToString, Me.Font, Brushes.Black, e.CellBounds, sf)
e.Handled = True
End If
End Sub
Entry filed under: VB.NET. Tags: .
Trackback this post | Subscribe to the comments via RSS Feed