| Platform: | Visual Basic |
| Task: | Set a report's binding source |
| Discussion: | You've set up a report with a datasource, but when you call the report there is no data. This is because the report forgets it's bindingsource, a known bug. Just reset the binding source when the form loads and on the bindingsource's CurrentChanged event. |
| Example: | Private Sub TblVitalSignsBindingSource_CurrentChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TblVitalSignsBindingSource.CurrentChanged
SetReportBindingSource()
End Sub
Private Sub SetReportBindingSource()
Dim vsbs As New BindingSource(Me.TblVitalSignsBindingSource, "")
Me.ReportViewer1.LocalReport.DataSources(0).Value = vsbs
Me.ReportViewer1.RefreshReport()
End Sub |