MS Report Viewer中单元格中的多个字段

时间:2023-02-02 08:17:46

In a C# based Win forms application I am working on a report using Microsoft Report Viewer. There is a requirement that I have to display multiple fields in one cell of the table, all in a new line.

在基于C#的Win表单应用程序中,我正在使用Microsoft Report Viewer处理报表。需要我必须在表的一个单元格中显示多个字段,所有字段都在一个新行中。

  • I have tried to use new line characters in expression but didnt work. There is no multi-line property of textbox.
  • 我试图在表达式中使用新行字符,但没有工作。文本框没有多行属性。
  • I have tried to use a list with multiple textboxes in the cell. But
    it gives error that:
  • 我试图在单元格中使用包含多个文本框的列表。但它给出了错误:

The tablix has a detail member with inner members. Detail members can only contain static inner members

Tablix具有带内部构件的细节构件。细节成员只能包含静态内部成员

Some people say something like adding groups but I could not figure how to do this.

有些人说像添加组,但我无法想象如何做到这一点。

Could you please let me know how can show multiple fields in row like:

能告诉我如何在行中显示多个字段,如:

Product Name
Product Color
Poduct Size

Thanks to @Hemant's suggestion I managed to solve it like this:

感谢@ Hemant的建议,我设法解决了这个问题:

In Report -> Report Properties -> Code, I entered this code:

在报告 - >报告属性 - >代码中,我输入了以下代码:

Function GetBreakupstring(value) as String

    return value.Replace("--M--", Environment.NewLine) 

End Function

In Textbox's expression I entered:

在Textbox的表达式中,我输入了:

=Code.GetBreakupstring(Fields!Name.Value & "--M--" & Fields!IDProducts.Value & "--M--" & Fields!Color.Value)

Then I tried to simple use Environment.NewLine in expression which I also worked. This is what expression is looking right now:

然后我尝试简单地在表达式中使用Environment.NewLine,我也工作了。这就是现在表达的看法:

=Fields!Name.Value & Environment.NewLine & Fields!IDProducts.Value & Environment.NewLine & Fields!Color.Value

1 个解决方案

#1


2  

you can write a function in VB Code that breaks your input into multiple line and call that function in text box as Textbox expression= Code.GetBreakupstring(field.parameter)

你可以在VB代码中编写一个函数,将输入分成多行并在文本框中调用该函数,如Textbox expression = Code.GetBreakupstring(field.parameter)

and write this public sub GetBreakupstring(value){

并编写此公共子GetBreakupstring(value){

return break value; }

回报值; }

#1


2  

you can write a function in VB Code that breaks your input into multiple line and call that function in text box as Textbox expression= Code.GetBreakupstring(field.parameter)

你可以在VB代码中编写一个函数,将输入分成多行并在文本框中调用该函数,如Textbox expression = Code.GetBreakupstring(field.parameter)

and write this public sub GetBreakupstring(value){

并编写此公共子GetBreakupstring(value){

return break value; }

回报值; }