c# - How to add rdlc file to ReportViewer in WPF projects -


i've added reportviewer in wpf app via xaml designer of main window , i'd add existing rdlc file it.

i'd reportviewer show empty rdlc file (without parameters) on startup, , later upon selecting row datagrid (bound observablecollection) change parameters accordingly , show filled report definition instead of empty one.

i'll make button selected row commandparameter , relevant events , everything, need able pass data report. realize not easy question i'll try simplify:

  1. how add existing rdlc file reportviewer (mvvm, wpf) ?
  2. i push button -> relevant command gets item observablecollection parameter (a row in datagrid) -> how pass data parts of item unfilled (or overwrite if filled of course) parts of report?

i hope i've been clear. answer in advance!

after set initilizemethod correct path report , dataset name this.

private void initializereport()         {             this.mform_components = new system.componentmodel.container();             microsoft.reporting.winforms.reportdatasource reportdatasource1 = new microsoft.reporting.winforms.reportdatasource();              this.productbindingsource = new system.windows.forms.bindingsource(this.mform_components);             ((system.componentmodel.isupportinitialize)(this.productbindingsource)).begininit();              reportdatasource1.name = "dataset4";             reportdatasource1.value = this.productbindingsource;              this.viewerinstance.localreport.datasources.add(reportdatasource1);             this.viewerinstance.localreport.reportembeddedresource = "yourreport.rdlc";             this.viewerinstance.zoompercent = 95;             this.windowsformshost1.width = 680;              ((system.componentmodel.isupportinitialize)(this.productbindingsource)).endinit();     } 

only thing should left specifing object want se in report.

private system.windows.forms.bindingsource productbindingsource;         private void startreport()         {             yourclass item  = (yourclass)datagridview.selecteditem;             this.productbindingsource.datasource = item;              this.viewerinstance.refreshreport();             this.viewerinstance.refresh();         } 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -