listview标题文本的垂直文本对齐方式

问题描述 投票:0回答:1

如何设置listview对象的标题列的垂直对齐以适合单元格边框内的文本(无法自动设置标题表单的高度)

有些文字没有显示如下; Listview screenshot

   ListView1.Columns.Add(items.InnerText, 90, HorizontalAlignment.Center)

将“strformat”添加到drawcolumnheader正在进行水平对齐,但不适用于垂直对齐

 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
vb.net listview textwrapping
1个回答
0
投票

根据@Jimi的建议,处理标题文本对齐的最佳方法是使用Datagridview而不是Listview。 Datagridview具有许多功能,包括标题文本,行和列调整。

© www.soinside.com 2019 - 2024. All rights reserved.