以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]listview标题行居中对齐  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=108161)

--  作者:kb9701
--  发布时间:2017/10/17 15:06:00
--  [求助]listview标题行居中对齐
如题,标题行居中,数据不需要居中
没找到单独设置的,只有lvw.Columns("人口").TextAlign = HorizontalAlignment.Right \'人口列靠右对齐
只能修改整列对齐方式。。。
[此贴子已经被作者于2017/10/17 15:06:47编辑过]

--  作者:有点甜
--  发布时间:2017/10/17 17:27:00
--  

 可以绘制单元格 DrawViewCell

 

http://www.foxtable.com/webhelp/scr/2874.htm

 

 

e.DrawDefault = False \'取消默认的绘制
Dim g As Graphics = e.Graphics
Dim sf As new StringFormat
Dim cs1() As String = {"国家","备注","宗教"}
Dim cs2() As String = {"语言"}
Dim cs3() As String = {"日期", "人口"}
If array.Indexof(cs1, e.Col.name) >= 0 Then
    sf.Alignment = StringAlignment.near
    sf.LineAlignment = StringAlignment.near
ElseIf array.Indexof(cs2, e.Col.name) >= 0 Then
    sf.Alignment = StringAlignment.Center
    sf.LineAlignment = StringAlignment.Center
ElseIf array.Indexof(cs3, e.Col.name) >= 0 Then
    sf.Alignment = StringAlignment.far
    sf.LineAlignment = StringAlignment.far
Else
    sf.Alignment = StringAlignment.near
    sf.LineAlignment = StringAlignment.near
End If

Dim fnt As New Font("宋体",9)
Dim msg As String = e.Row(e.Col.name)
g.DrawString(msg,fnt,Brushes.black,  new Rectangle(e.x, e.y, e.width, e.height), sf)