Begginnerdev
Practically a Posting Shark
861 posts since Apr 2010
Reputation Points: 184
Solved Threads: 141
Skill Endorsements: 8
I have written a datadriven application that works with Report Viewer reports.
You will need to look at embedding the reports in the project and calling them when needed.
Begginnerdev
Practically a Posting Shark
861 posts since Apr 2010
Reputation Points: 184
Solved Threads: 141
Skill Endorsements: 8
I may be mistaken here, but under VB2010 Express you can use the ReportViewer control, however you will not have design time support for either the control nor the Report. The only way I have been able to make this work is to add the control to the Form via your own code.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'ReportViewer1
'
' place and size the control
Me.ReportViewer1.Location = New System.Drawing.Point(10, 10)
Me.ReportViewer1.Name = "ReportViewer1"
Me.ReportViewer1.Size = New System.Drawing.Size(300, 200)
Me.ReportViewer1.TabIndex = 0
Me.ReportViewer1.Parent = Me
' the next line load the XML report file for the application directory.
' you can locate the file anywhere you wish, just adjust the path
Me.ReportViewer1.LocalReport.ReportPath = ".\Report1.rdlc"
' tells the viewer to refresh with the currently loaded report
Me.ReportViewer1.RefreshReport()
End Sub
Sample report definition file:
<?xml version="1.0" encoding="utf-8"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<InteractiveHeight>11in</InteractiveHeight>
<rd:DrawGrid>true</rd:DrawGrid>
<InteractiveWidth>8.5in</InteractiveWidth>
<rd:SnapToGrid>true</rd:SnapToGrid>
<RightMargin>1in</RightMargin>
<LeftMargin>1in</LeftMargin>
<BottomMargin>1in</BottomMargin>
<rd:ReportID>2ae1843f-1c7c-4caf-80ae-3fd92ba70b98</rd:ReportID>
<Width>6.5in</Width>
<Body>
<ReportItems>
<Textbox Name="textbox2">
<rd:DefaultName>textbox2</rd:DefaultName>
<Top>0.125in</Top>
<Width>1.125in</Width>
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
<CanGrow>true</CanGrow>
<Left>0.25in</Left>
<Height>0.375in</Height>
<Value>hello</Value>
</Textbox>
</ReportItems>
<Height>2in</Height>
<Style>
<BackgroundColor>LightGrey</BackgroundColor>
</Style>
</Body>
<Language>en-US</Language>
<TopMargin>1in</TopMargin>
</Report>
TnTinMN
Practically a Master Poster
640 posts since Jun 2012
Reputation Points: 418
Solved Threads: 148
Skill Endorsements: 13
Actually VB 2010 Express can load the report viewer in design time. It works quite well.
tinstaafl
Nearly a Posting Virtuoso
1,291 posts since Jun 2010
Reputation Points: 341
Solved Threads: 223
Skill Endorsements: 14
right-click on the toolbox and select 'choose items...'. I chose Report Viewer, Namespace - Microsoft.Reporting.Winforms, Assembly Name - Microsoft.ReportViewer.Winforms(10.0.0.0). You'll have to resize the columns to see everything. I'm using VB 2010 Express. And just to make sure it worked I tested it with TnTinMN's sample file. I used
' the next line load the XML report file for the application directory.
' you can locate the file anywhere you wish, just adjust the path
Me.ReportViewer1.LocalReport.ReportPath = ".\Report1.rdlc"
' tells the viewer to refresh with the currently loaded report
Me.ReportViewer1.RefreshReport()
from TnTinMN's code, to display the report, and it worked well.
tinstaafl
Nearly a Posting Virtuoso
1,291 posts since Jun 2010
Reputation Points: 341
Solved Threads: 223
Skill Endorsements: 14
You might have to add a couple of references, Microsof.ReportViewer.Common, and Microsoft.ReportViewer.Winforms
tinstaafl
Nearly a Posting Virtuoso
1,291 posts since Jun 2010
Reputation Points: 341
Solved Threads: 223
Skill Endorsements: 14
how are you trying to add the references? I right-click in the solution explorer and select Add References
tinstaafl
Nearly a Posting Virtuoso
1,291 posts since Jun 2010
Reputation Points: 341
Solved Threads: 223
Skill Endorsements: 14
tinstaafl
Nearly a Posting Virtuoso
1,291 posts since Jun 2010
Reputation Points: 341
Solved Threads: 223
Skill Endorsements: 14