栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

SSRS-动态隐藏列时,表格的宽度保持相同吗?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

SSRS-动态隐藏列时,表格的宽度保持相同吗?

我知道如何完成此操作的唯一方法是在运行时更改RDLC文件。基本上,您可以将RLDC文件加载到内存中(它只是一个XML文件),找到包含表宽度的XML节点-
然后修改内存中的设置。完成此操作后,您可以使用内存中加载的RDLC文件刷新reportViewer控件。

是的,我已经做到了,它确实有效。

下面的代码示例通过其XMLpath更改内存中RDLC文件的数据。

  Private Sub ModifyRDLCInMemory()    Dim xmlDoc As Xmldocument = New Xmldocument    Dim asm As Reflection.Assembly = Reflection.Assembly.GetExecutingAssembly()    'create in memory, a XML file from a embedded resource    Dim xmlStream As Stream = asm.GetManifestResourceStream(ReportViewer1.LocalReport.ReportEmbeddedResource)    Try      'Load the RDLC file into a XML doc      xmlDoc.Load(xmlStream)    Catch e As Exception      MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1)    End Try    'Create an XmlNamespaceManager to resolve the default namespace    Dim nsmgr As XmlNamespaceManager = New XmlNamespaceManager(xmlDoc.Nametable)    nsmgr.AddNamespace("nm", "http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition")    nsmgr.AddNamespace("rd", "http://schemas.microsoft.com/SQLServer/reporting/reportdesigner")    'Loop through each node in the XML file    Dim node As XmlNode    For Each node In xmlDoc.documentElement.SelectNodes(String.Format("//nm:{0}[@rd:LocID]", "Value"), nsmgr)  'XPath to LocID node.. You will want to change this to locate your Table Width node. You may need to read up on XMLPath      Dim nodevalue As String = node.InnerText  'Gets current value of Node      If (String.IsNullOrEmpty(nodevalue) Or Not nodevalue.StartsWith("=")) Then        Try          node.InnerText = YOURNEWVALUE        Catch ex As Exception          'handle error        End Try      End If    Next    ReportViewer1.LocalReport.ReportPath = String.Empty    ReportViewer1.LocalReport.ReportEmbeddedResource = Nothing    'Load the updated RDLC document into LocalReport object.    Dim rdlcOutputStream As StringReader = New StringReader(xmlDoc.documentElement.OuterXml)    Using rdlcOutputStream      ReportViewer1.LocalReport.LoadReportDefinition(rdlcOutputStream)    End Using  End Sub


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/420182.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号