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
StringFormatis working as expected. Your problem is that there's not enough vertical space to contain your strings. 3 of the possible solutions, I've listed in the previous comment. - Jimi