473,385 Members | 2,269 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Changing text in Report viewer

Hi All

I need to change text in a Report Viewer document at runtime

It is just the heading I want to change to match what the user has chosen as
the Report to view

How do I access the textbox in "GymMaster.Memberships.rdlc" (below) to
change the text
sql = "select * from members order by surname"

dt = getdata(sql)

If Me.ReportViewer1.LocalReport.DataSources.Count > 0 Then

Me.ReportViewer1.LocalReport.DataSources.RemoveAt( 0)

End If

Me.ReportViewer1.LocalReport.ReportEmbeddedResourc e =
"GymMaster.Memberships.rdlc"

Me.ReportViewer1.LocalReport.DataSources.Add(New
Microsoft.Reporting.WinForms.ReportDataSource("Gym _masterDataSet_Members",
dt))

Me.ReportViewer1.RefreshReport()

Regards
Steve
Jun 9 '06 #1
7 27596
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("Nor thwindDataSet_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.)

Jun 9 '06 #2
steve wrote:
How do I access the textbox in "GymMaster.Memberships.rdlc" (below) to
change the text


Another way you could do this is by setting the textbox to display its value
from a datasource rather than hard-coding the value into the report
definition. Then you can just give a DataTable to the report viewer and
it'll display the appropriate value from within.

--

(O)enone
Jun 9 '06 #3
Steven

Thanks very much for both your posts

Exactly what I was looking for
Regards
Steve

"Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
news:GL**************@TK2MSFTNGXA01.phx.gbl...
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("Nor thwindDataSet_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.)

Jun 9 '06 #4
Oenone

Thanks for the post

An interesting concept which I hadn't thought of

I will experiment
Regards
Steve

"Oenone" <oe****@nowhere.com> wrote in message
news:3A**************@newsfe3-win.ntli.net...
steve wrote:
How do I access the textbox in "GymMaster.Memberships.rdlc" (below) to
change the text


Another way you could do this is by setting the textbox to display its
value from a datasource rather than hard-coding the value into the report
definition. Then you can just give a DataTable to the report viewer and
it'll display the appropriate value from within.

--

(O)enone

Jun 9 '06 #5
You're welcome Steve,

Glad to be of assistance. BTW, I also think Oenone's suggestion a good idea
:).

Have a good day!

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.)

Jun 10 '06 #6
Hi All

I have created rdlc files and when I load them into Report Viewer at run
time they appear OK

If I click on 'Print layout' button on Report Viewer the view again appears
acceptable

If I click on 'Page setup' button the margins left & right are not what I
set on the rdlc file at design time (1.5cm) they are 5.9mm

If I click OK on the 'Page Setup' form the Report margins change to the
margins from 'Page setup'

If I open ''Page setup' again the margin settings are now less than
previously set and clicking OK results in the report margins changing again
What am I missing??
Regards
Steve

"Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
news:cq**************@TK2MSFTNGXA01.phx.gbl...
You're welcome Steve,

Glad to be of assistance. BTW, I also think Oenone's suggestion a good
idea
:).

Have a good day!

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.)

Jun 10 '06 #7
Hi Steve,

I've seen your new thread on this issue and posted my response in that
thread. As I also mentioned there, if you feel it convenient that we
continue discussing in that thread, please feel free to followup there. And
I'll close this thread first.

Thanks for your understanding.

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.)

Jun 12 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Dean Sabella | last post by:
Hi, I was trying to run a crystal report in the .net sample application given at: http://support.crystaldecisions.com/communityCS/FilesAndUpdates/ cppnet_win_subreport_basic.exe.asp (I've...
0
by: louise raisbeck | last post by:
Hi, The first part of this code def works as i have an export function which saves my crystal report, as a pdf, to disk. However they want to be able to view them before deciding to save them. I...
2
by: zdrakec | last post by:
Hello all: I have the Crystal Report viewer imbedded on a .NET form, and it works very well... except, on the target machine, when I set the ReportSource property of the viewer (to a...
0
by: Chris | last post by:
I have the following situation in a VB.Net App I am working on: 1.)A report created in VS.Net 2003 using the CR.Net component of VS 2003. 2.)The datasource for the report is a Stored Proc in a...
1
by: monskie | last post by:
Hello to all, I have a problem which could be trivial to you guys. This concerns opening several crystal reports on the a crystal viewer on an ASPX page by calling window.open. My...
4
by: VMI | last post by:
For my website, I created CrystalReportTest.rpt (through the designer in VS 2005) and I'd like to be able to display it in viewer.aspx (all in the same project). Viewer.aspx has a Crystal Report...
0
by: Tumurbaatar S. | last post by:
It's my first project using the Crystal report. I created a report with the report designer and linked it to a web form as: 1. put CrystalReportViewer in my page (its ID: Viewer). 2. put...
0
by: John Smith | last post by:
Hello, I am developing a VB.NET 2003 application that will use lots of Crystal Reports. Sometimes the users will preview a report in a Crystal report viewer, and sometimes they will send the...
0
by: mike11d11 | last post by:
I have a simple report viewer in on one of my web pages and I have a specific report chosen to view, not a crystal report but the built in reports that are .rdlc files. I want to be able to send...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.