且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在RDLC报告中用新行替换空间

更新时间:2023-12-03 17:49:16

参见 System.String.Replace(String,String) [ ^ ]。第一个参数是旧值(要替换的字符串),第二个参数是要插入的字符串。你已经传递了这些互换的参数。



另请注意,您可能希望替换逗号(使用可选的尾随空格)。否则你也会从你的例子中拆分包含T2 Terminal International Airport等空格的字符串。



所以使用

替换( ,System.Environment.NewLine)


if Insert Address like...

T2 Terminal International Airport,
MTNL Road,
Andheri,
Sakinaka,
Mumbai,
Maharashtra


in Rdlc report show like this
T2 Terminal International Airport, MTNL Road, Andheri, Sakinaka, Mumbai,Maharashtra.

please Suggest how to replace space with new line...

What I have tried:

=First(Fields!address.Value, "DataSet4").ToString().Replace(System.Environment.NewLine," ")



=Replace(First(Fields!address.Value, "DataSet4"),System.Environment.NewLine," ")

See System.String.Replace(String, String)[^]. The first parameter is the old value (the string to be replaced), and the second one is the string to be inserted. You have passed these parameters interchanged.

Note also that you probably want to replace the comma instead (with optional trailing space). Otherwise you would also split strings containing spaces like "T2 Terminal International Airport" from your example.

So use
Replace(", ", System.Environment.NewLine)