listView1.View
=
View.Details
listView1.Columns.Add("姓名")
listView1.Columns.Add("语文")
listView1.Columns.Add("数学")
listView1.Columns.Add("科学")
listView1.Columns.Add("英语")
string[,]
chengji
=
new
string[4,
5]
chengji[0,
0]
=
"小王"
chengji[0,
1]
=
"90"
chengji[0,
2]
=
"98"
chengji[0,
3]
=
"88"
chengji[0,
4]
=
"92"
chengji[1,
0]
=
"小李"
chengji[1,
1]
=
"92"
chengji[1,
2]
=
"94"
chengji[1,
3]
=
"98"
chengji[1,
4]
=
"93"
chengji[2,
0]
=
"小黄"
chengji[2,
1]
=
"91"
chengji[2,
2]
=
"92"
chengji[2,
3]
=
"93"
chengji[2,
4]
=
"94"
chengji[3,
0]
=
"小张"
chengji[3,
1]
=
"95"
chengji[3,
2]
=
"94"
chengji[3,
3]
=
"93"
chengji[3,
4]
=
"92"
1、第一种分列显示方法:
listView1.Clear()
for
(int
i
=
0
i
<
chengji.GetLength(0)
i++)
{
ListViewItem
bb
=
new
ListViewItem(new
string[]
{
chengji[i,
0],
chengji[i,
1],
chengji[i,
2],
chengji[i,
3],
chengji[i,
4]
})
listView1.Items.Add(bb)
}
2、第二种分列显示方法:
上面的listview分列显示还可以用下面的方法。
listView1.Clear()
ListViewItem
cj
for
(int
i
=
0
i
<
chengji.GetLength(0)
i++)
{
cj
=
new
ListViewItem(chengji[i,0])
cj.SubItems.Add(chengji[i,
1])
cj.SubItems.Add(chengji[i,2])
cj.SubItems.Add(chengji[i,
3])
cj.SubItems.Add(chengji[i,
4])
listView1.Items.Add(cj)
3、第三种分列显示方法:
如果我们把二维数组转化为一维数组(即结合上面两种方法)还可以用下面的方法分列显示。
listView1.Clear()
ListViewItem
cjj
string[]
sstr
=
new
string[chengji.GetLength(1)]
for
(int
i
=
0
i
<
chengji.GetLength(0)
i++)
{
for
(int
j
=
0
j
<
chengji.GetLength(1)
j++)
{
sstr[j]
=
chengji[i,
j]
}
cjj
=
new
ListViewItem(sstr)
listView1.Items.Add(cjj)
}
绑定的时候:foreach (var item in ac)
{
ListViewItem ii = new ListViewItem(item.gonghao)
ii.SubItems.Add(item.name)
ii.SubItems.Add(item.Sex)
ii.SubItems.Add(item.age)
ii.SubItems.Add(item.pingjia)
ii.SubItems.Add(item.defen)
this.listView1.Items.Add(ii)
}
sReplace = "|", $sHeader = "")If Not IsArray($avArray) Then Return SetError(1, 0, 0)
Local $iDimension = UBound($avArray, 0), $iUBound = UBound($avArray, 1) - 1, $iSubMax = UBound($avArray, 2) - 1
If $iDimension >2 Then Return SetError(2, 0, 0)
If $sSeparator = "" Then $sSeparator = Chr(124)
If _ArraySearch($avArray, $sSeparator, 0, 0, 0, 1) <>-1 Then
For $x = 1 To 255
If $x >= 32 And $x <= 127 Then ContinueLoop
Local $sFind = _ArraySearch($avArray, Chr($x), 0, 0, 0, 1)
If $sFind = -1 Then
$sSeparator = Chr($x)
ExitLoop
EndIf
Next
EndIf
Local $vTmp, $iBuffer = 4094
Local $iColLimit = 250
Local $iOnEventMode = Opt("GUIOnEventMode", 0), $sDataSeparatorChar = Opt("GUIDataSeparatorChar", $sSeparator)
If $iSubMax <0 Then $iSubMax = 0
If $iTranspose Then
$vTmp = $iUBound
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)