จากข้อความ "DataGridview HeaderText จัดรูปแบบ 90 องศา"
1.ผลที่ต้องการ
2.Code ครับ
Private Sub Createcolumn()
Dim dt3 As New DataTable
dt3.Columns.Add("Column1")
dt3.Columns.Add("Column2")
dt3.Columns.Add("Column3")
dt3.Columns.Add("Column4")
dt3.Columns.Add("Column5")
dt3.Columns.Add("Column6")
dt3.Columns.Add("Column7")
dt3.Columns.Add("Column8")
dt3.Columns.Add("Column9")
dt3.Columns.Add("Column10")
With dt3
For i As Integer = 0 To 20
.Rows.Add(i)
Next
End With
With DataGridView2
.DataSource = dt3
End With
With DataGridView2
.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
.ColumnHeadersHeight = 80
.RowHeadersVisible = False
For i As Integer = 0 To .Columns.Count - 1
.Columns(i).Width = 25
Next
End With
End Sub
Private Sub DataGridView2_CellPainting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellPaintingEventArgs) Handles DataGridView2.CellPainting
If e.RowIndex = -1 Then
e.PaintBackground(e.CellBounds, True)
e.Graphics.TranslateTransform(e.CellBounds.Left, e.CellBounds.Bottom)
e.Graphics.RotateTransform(270)
e.Graphics.DrawString(e.FormattedValue.ToString, e.CellStyle.Font, Brushes.Blue, 5, 5)
e.Graphics.ResetTransform()
e.Handled = True
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Createcolumn()
End Sub
No comments:
Post a Comment