Dim lsv As System.Windows.Forms.ListView = e.Form.Controls("ListView1").BaseControl
RemoveHandler lsv.ColumnClick, AddressOf Listview1_ColumnClick
lsv.ListViewItemSorter = Nothing
Dim lvw As WinForm.ListView = e.Form.Controls("ListView1")
lvw.StopRedraw() '暂停绘制
lvw.Columns.Clear() '清除原来的列
lvw.Rows.Clear() '清除原来的行
lvw.Images.Clear() '清除原来的图片
lvw.View = ViewMode.Details '显示模式为详细信息
lvw.GridLines = True '显示网格线
Dim cls() As String = {"国家","人口","面积","语言","宗教","洲"} '指定要显示的各列
For Each c As String In cls
Dim cl As object = lvw.Columns.Add
cl.Name = c
cl.Text = c
Next
lvw.Columns("人口").Text = "人口(万)" '修改人口列的标题
lvw.Columns("人口").TextAlign = HorizontalAlignment.Right '人口列靠右对齐
lvw.Columns("面积").TextAlign = HorizontalAlignment.Right '面积列靠右对齐
For Each dr As DataRow In DataTables("国家").DataRows '从数据表中提取数据
Dim Key As String = dr("图标")
Dim r As WinForm.ListViewRow = lvw.Rows.Add() '增加一行
lvw.Images.AddImage(Key, Key & ".ico", Key & "48.ico") '添加代表这个国家的一对图标
r.ImageKey = Key '指定图标键值
For Each cl As String In cls '逐列取值
Select Case cl
Case "人口","面积" '如果是人口列或面积列
'r(cl) = format(dr(cl),"#,000") '则显示千位分割符号
r(cl) = dr(cl)
Case Else
r(cl) = dr(cl)
End Select
Next
Next
lvw.ResumeRedraw() '恢复绘制
AddHandler lsv.ColumnClick, AddressOf Listview1_ColumnClick
lsv.ListViewItemSorter = new ListViewColumnSorter