473,545 Members | 1,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Memb erships.rdlc" (below) to
change the text
sql = "select * from members order by surname"

dt = getdata(sql)

If Me.ReportViewer 1.LocalReport.D ataSources.Coun t > 0 Then

Me.ReportViewer 1.LocalReport.D ataSources.Remo veAt(0)

End If

Me.ReportViewer 1.LocalReport.R eportEmbeddedRe source =
"GymMaster.Memb erships.rdlc"

Me.ReportViewer 1.LocalReport.D ataSources.Add( New
Microsoft.Repor ting.WinForms.R eportDataSource ("Gym_masterDat aSet_Members",
dt))

Me.ReportViewer 1.RefreshReport ()

Regards
Steve
Jun 9 '06 #1
7 27630
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.)

Jun 9 '06 #2
steve wrote:
How do I access the textbox in "GymMaster.Memb erships.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******** ******@TK2MSFTN GXA01.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.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.)

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.Memb erships.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******** ******@TK2MSFTN GXA01.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
3624
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 reproduced the relevant file below.)
0
1558
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 have just started learning about the CRviewer and have added the three lines at the bottom, but it fails on showFirstPage (object not set to an...
2
8156
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 ReportDocument object), it PRETENDS to load a report, but displays a blank object. The toolbar becomes active, the navigation buttons are active, but otherwise...
0
2253
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 SQL Server DB (pull method). 3.)The Stored Proc has two input parameters of type date. 4.)The Stored Proc is a rather complex proc that was not...
1
7498
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 application. 1.) 2 webforms - 1 main web form that filters that dataset - 1 reportviewer web form that displays the filtered dataset.
4
5465
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 viewer but for some reason, I can't create an instance of this report. Therefore, I can't set any of its properties. The only way I was able to run it...
0
1975
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 ReportDocument component from Toolbox | Components (its Name: Report) and specified my existing report class (myproject.import.reports.shiporder). 3. in...
0
2952
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 report directly to the printer bypassing the Crystal report viewer altogether. When sending the job directly to the printer I use the PrintToPrinter...
0
1438
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 parameters to this report to change the data shown. I initially want to pull the report up based on one parameter (Users ID), then give the user the...
0
7464
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7396
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7413
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7751
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5323
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
1874
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
700
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.