WPF (xaml & C#) - Problème lors de l'utilisation des fichiers .rdlc
Bonjour,
je suis en train d'essayer de faire du reporting, mais un problème se pose à moi lors de l'utilisation des fichiers .rdlc ...
En effet le fichier ne se génère pas toujours et de plus les boutons liés au rapport ne sont pas cliquable (comme lorsque Visual Studio plante pour vous donner un exemple ;) )
Voila le code que j'essaye d'utiliser pour faire cela :
dans mon fichier xaml :
Code:
1 2 3
| <WindowsFormsHost>
<viewer:ReportViewer x:Name="viewerInstance"/>
</WindowsFormsHost> |
et voici le code behind
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
private System.Windows.Forms.BindingSource bindingSource;
private System.ComponentModel.IContainer component= null;
private Microsoft.Reporting.WinForms.ReportDataSource reportDataSource;
private void PrepareReport()
{
// on commence par définir les data sources
this.component= new System.ComponentModel.Container();
this.reportDataSource= new Microsoft.Reporting.WinForms.ReportDataSource();
this.bindingSource = new System.Windows.Forms.BindingSource(this.component);
((System.ComponentModel.ISupportInitialize)this.bindingSource).BeginInit();
this.reportDataSource.Name = "Post";
this.reportDataSource.Value = this.bindingSource;
// puis à ajouter la data source au rapport
this.viewerInstance.LocalReport.DataSources.Add(reportDataSource);
// paramètres du rapport
this.viewerInstance.LocalReport.ReportPath = @"./Reports/AR.rdlc";
this.viewerInstance.Location = new System.Drawing.Point(0, 0);
this.viewerInstance.ShowDocumentMapButton = true;
this.viewerInstance.ShowBackButton = true;
this.viewerInstance.ShowPageNavigationControls = true;
this.viewerInstance.RefreshReport();
((System.ComponentModel.ISupportInitialize)this.bindingSource).EndInit();
}
public void Report(ObjetMetier1 objetMetier)
{
this.bindingSource.DataSource = objetMetier
this.viewerInstance.RefreshReport();;
} |
Voila, donc si vous aviez une petite idée du problème ce serait vraiment interessant !
ps : la fonction PrepareReport n'est appelée que la première fois, alors que la fonction Reportest appelée à chaque génération de rapport.
D'ailleur il semblerait que le problème ne survienne que lorsque je change le data source :s
Bref,
quelqu'un aurait une petite idée ?
Merci d'avance et bonne journée.