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.Lo calReport, it has provided several means to
specify the Local Report's definition template. If we use the
"LocalReport.Re portPath" or "LocalReport.Re portEmbeddedRes ource" 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 "LoadReportDefi nition",
this provide us the chance to manually load and supply the rdlc template(so
that we can customize it before assign to reportviewer)
#LocalReport.Lo adReportDefinit ion 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(u se 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.EventArg s) Handles btnClientTest2. Click
Me.ReportViewer 1.Reset()
Me.ReportViewer 1.ProcessingMod e =
Microsoft.Repor ting.WinForms.P rocessingMode.L ocal
Dim newds As New
Microsoft.Repor ting.WinForms.R eportDataSource ("NorthwindData Set_Categories" )
newds.Value = Me.CategoriesBi ndingSource
Me.ReportViewer 1.LocalReport.D ataSources.Add( newds)
' load the customized report template
Me.ReportViewer 1.LocalReport.L oadReportDefini tion(GetCustomi zedReportDefini t
ion("ClientRepo rtApp.Report1.r dlc"))
Me.ReportViewer 1.RefreshReport ()
End Sub
Private Function GetCustomizedRe portDefinition( 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.GetMan ifestResourceSt ream(rdlc)
doc.Load(stream )
Dim node As Xml.XmlNode
Dim nsmgr As New Xml.XmlNamespac eManager(doc.Na meTable)
nsmgr.AddNamesp ace("dns",
"http://schemas.microso ft.com/sqlserver/reporting/2005/01/reportdefinitio n")
node =
doc.SelectSingl eNode("//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.)