如果只是要消除 顯示的 三角形
padding的參數中 設個數值就好
datagridview1.RowHeadersDefaultCellStyle.Padding = New Padding(50)
單純 設定 RowHeade 的文字
以設定行號為例
For i As Integer = 0 To datagridview1.Rows.Count - 1
datagridview1.Rows(i).HeaderCell.ValueType = GetType(String)
datagridview1.Rows(i).HeaderCell.Value = i.ToString("00")
Next
如果要顯示 文字 又要消除三角形 需要修改 RowHead 的 Paint 事件
datagridview1.RowHeadersDefaultCellStyle.Padding = New Padding(50)
AddHandler datagridview1.RowPostPaint, AddressOf datagridview1_RowPostPaint
Private Sub datagridview1_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs)
Dim o As Object = datagridview1.Rows(e.RowIndex).HeaderCell.Value
If Not IsNothing(o) Then
e.Graphics.DrawString(o.ToString(), datagridview1.Font, Brushes.Black, New PointF(e.RowBounds.Left + 2, (e.RowBounds.Top + 7)))
End If
End Sub
留言列表