How can i set vertical alignment of header column of listview object to fit the text within the cell border ( cannot set the height of the header form automatically)
Some of the text are not shown as seen below ;
ListView1.Columns.Add(items.InnerText, 90, HorizontalAlignment.Center)
adding "strformat" to drawcolumnheader is working for horizontal alignment but not for vertical
Private Sub ListView3_DrawColumnHeader(sender As Object, e As DrawListViewColumnHeaderEventArgs) Handles ListView3.DrawColumnHeader
Dim strFormat As New StringFormat()
If e.Header.TextAlign = HorizontalAlignment.Center Then
strFormat.LineAlignment = StringAlignment.Center
strFormat.Alignment = StringAlignment.Center
ElseIf e.Header.TextAlign = HorizontalAlignment.Right Then
strFormat.LineAlignment = StringAlignment.Far
End If
e.DrawBackground()
e.Graphics.FillRectangle(Brushes.SteelBlue, e.Bounds)
Dim headerFont As New Font("Arial", 8, FontStyle.Bold)
e.Graphics.DrawString(e.Header.Text, headerFont, Brushes.White, e.Bounds, strFormat)
End Sub
As recommended by @Jimi the best way to handle the header text alignment is using Datagridview instead of Listview. Datagridview has lots of features both with header text, rows and columns adjustment.