DataGridView
値の確定
Me.DataGridView1.EndEdit()
For i = 0 To Me.DataGridView1.RowCount - 1
Me.DataGridView1(0, i).Value = True
Next
Me.DataGridView1.UpdateCellValue(0, Me.DataGridView1.CurrentCell.RowIndex)
行番号を付ける
Private Sub DataGridView1_CellPainting(ByVal sender As Object, _
ByVal e As DataGridViewCellPaintingEventArgs) _
Handles DataGridView1.CellPainting
'行ヘッダーに行番号を表示する
'列ヘッダーかどうか調べる
If (e.ColumnIndex < 0) AndAlso (e.RowIndex >= 0) Then
'セルを描画する
e.Paint(e.ClipBounds, DataGridViewPaintParts.All)
'行番号を描画する範囲を決定する
'e.AdvancedBorderStyleやe.CellStyle.Paddingは無視しています
Dim indexRect As Rectangle = e.CellBounds
indexRect.Inflate(-2, -2)
'行番号を描画する
TextRenderer.DrawText(e.Graphics, _
(e.RowIndex + 1).ToString(), _
e.CellStyle.Font, _
indexRect, _
e.CellStyle.ForeColor, _
TextFormatFlags.Right Or TextFormatFlags.VerticalCenter)
'描画が完了したことを知らせる
e.Handled = True
End If
End Sub
最終更新:2011年02月10日 12:47