如何添加这样的行号:
第1组
行号ID名称年龄
1 231 test 43
2 324 test2 45
3 354 test3 34
第2组
行号ID名称年龄
1 657 test4 43
2 534 test5 45
3 678 test6 34
我想像这个例子一样做行号。。对于每组,我的行号将重置,并从1开始分组行数。。我的groops(GROUP 1,GROUP 2,…)动态地来自db!我有多少组还不清楚!我在这里找到了一些解决方案,但我认为这些解决方案适用于我们知道的多少团体!
RDLC具有RowNumber("ScopeName")
函数。这将返回给定范围内记录的行号。
您可以在设计器下方的"行组"one_answers"列组"标题下查看报表的现有组。选择分组中需要行号的列并查看行列。默认名称为:
[(Group1)
≡(Details1)
将"行号"列的表达式设置为
=RowNumber("Group1")
右键单击您的Report属性,然后转到代码,然后将代码粘贴到下方
Dim private count as integer = 0
Dim private iniRow as integer = 0
Dim private iniGrp as Object = ""
Public function MatrixRow(Byval rowNum as integer,Byval rowGrp as Object) as integer
if iniGrp = "" then
iniGrp = rowGrp
end if
if rowGrp <> iniGrp then
iniRow = 0
count = 0
iniGrp = rowGrp
end if
if iniRow = 0 then
iniRow = rowNum
end if
if rowNum = iniRow then
count = 0
end if
count = count + 1
Return count
End function
然后像一样使用这个功能
=Code.MatrixRow(RowNumber(Nothing),(YourgroupfiledNameFromDataest))