0
到對象我上課命名爲「用戶」,代碼:如何創建報表查看器綁定在VB.NET
Public Class User
Private m_id As String
Private m_user_name As String
Public Sub New(ByVal id As String, ByVal name As String, ByVal pwd As String)
m_id = id
m_user_name = name
m_pwd = pwd
End Sub
Public Property Id() As String
Get
Return m_id
End Get
Set(ByVal value As String)
m_id = value
End Set
End Property
Public Property Name() As String
Get
Return m_user_name
End Get
Set(ByVal value As String)
m_user_name = value
End Set
End Property
End Class
我想報告所有用戶的信息,所以我也有一個名爲「其他類用戶「,代碼:
Public Class Users
inherits List(Of User)
Public Sub New()
'Query users' information from Table in Database
Add(New User(...)
End Sub
End Class
當我點擊」打印「按鈕,它會彈出報告。我只有一個帶有報表查看器的表單,但我有很多使用報表查看器的報表。所以我這樣的代碼:
Public Class Form1
Private Sub Form1_Load(...) Handles MyBase.Load
Dim bs As New BindingSource
bs.DataSource= New Users
Dim rpt As New Microsoft.Reporting.WinForms.ReportDataSource
rpt.Name = "Report_User"
rpt.Value = bs
ReportViewer1.LocalReport.DataSources.Add(rpt)
ReportViewer1.LocalReport.ReportEmbeddedResource = rpt.Name
ReportViewer1.RefreshReport()
End Sub
但它不會顯示任何東西......請幫我...我真的需要你的幫助..提前