How can add I rownumbers for each group on a RDLC Report?

空扰寡人 提交于 2019-12-09 13:36:06

问题


How can ı add row numbers like this:

GROUP 1

RowNumber ID Name Age

1            231     test     43
2            324     test2    45
3            354     test3    34

GROUP 2

RowNumber ID Name Age

1          657     test4    43
2          534     test5    45
3          678     test6    34

I want to do row numbers like this example.. For each group my row numbers will reset and start from 1 to groups row count.. My gruops(GROUP 1,GROUP 2, ....) are coming from db dynamically! How many group I have is not clear! here is I found some solutions but I think those solutions are available for how many groups when we know!


回答1:


RDLCs have a RowNumber("ScopeName") Function. This will return the row number of the record within the given scope.

You can see the existing groups for the report below the designer under a "Row Groups" and "Column Groups" headers. Select the column inside the grouping where you want the row number and view the Row Columns, The default names will be:

[(Group1)
 ≡(Details1)

Set the expression for the Row Number column to be

=RowNumber("Group1")



回答2:


Right Click on your Report property then go to code then paste the code below

   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

then use this function like

   =Code.MatrixRow(RowNumber(Nothing),(YourgroupfiledNameFromDataest))


来源:https://stackoverflow.com/questions/9770743/how-can-add-i-rownumbers-for-each-group-on-a-rdlc-report

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!