Hello Steve,
Thanks for your posting.
I've also seen your previous thread about the "VB 2005 reportviewer help"
and posted my suggestion on how to dynamically change the report's
datasource and refresh it. And as for your question in this thread, my
understanding is that you want to do some customization on the
reportViewer's LocalReport definiation content(rdlc) in program code at
runtime, correct?
As for the ReportViewer.LocalReport, it has provided several means to
specify the Local Report's definition template. If we use the
"LocalReport.ReportPath" or "LocalReport.ReportEmbeddedResource" property
to supply the rdlc template, we will be unable to intercept and modify the
report definition because the ReportViewer will load and parse the rdlc
content internally(from filestream or assembly resource stream).
However,
the LocalReport also provide another method named "LoadReportDefinition",
this provide us the chance to manually load and supply the rdlc
template(so
that we can customize it before assign to reportviewer)
#LocalReport.LoadReportDefinition Method (TextReader)
http://msdn2.microsoft.com/en-us/library/ms251812.aspx
for example, in the below code, I manually load the rdlc stream from
assembly resource and assign it to the reportviewer. And before assigning
the stream to reportviewer's localreport, I load it into a XmlDocument and
do some customization(use Xpath to locate the categoryName" textbox node
and modify it to a new value):
==========================
Private Sub btnClientTest2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnClientTest2.Click
Me.ReportViewer1.Reset()
Me.ReportViewer1.ProcessingMode =
Microsoft.Reporting.WinForms.ProcessingMode.Local
Dim newds As New
Microsoft.Reporting.WinForms.ReportDataSource("NorthwindDataSet_Categories")
newds.Value = Me.CategoriesBindingSource
Me.ReportViewer1.LocalReport.DataSources.Add(newds)
' load the customized report template
Me.ReportViewer1.LocalReport.LoadReportDefinition(GetCustomizedReportDefinit
ion("ClientReportApp.Report1.rdlc"))
Me.ReportViewer1.RefreshReport()
End Sub
Private Function GetCustomizedReportDefinition(ByVal rdlc As String) As
IO.TextReader
Dim reader As IO.TextReader
Dim doc As New Xml.XmlDocument
Dim stream As IO.Stream
stream = GetType(Form1).Assembly.GetManifestResourceStream(rdlc)
doc.Load(stream)
Dim node As Xml.XmlNode
Dim nsmgr As New Xml.XmlNamespaceManager(doc.NameTable)
nsmgr.AddNamespace("dns",
"
http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition")
node =
doc.SelectSingleNode("//dns:Table[@Name='table1']//dns:Header//dns:Textbox[@
Name='textbox2']/dns:Value", nsmgr)
node.InnerText = "new" & node.InnerText
reader = New IO.StringReader(doc.OuterXml)
Return reader
End Function
=============================
Hope this helps.
Regards,
Steven Cheng
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)