C# コード ビハインドでデータ ソースを提供する方法を見つけようとしています。すべてのレポートがリストされた 1 つのコンボボックスと、これらのレポートのプライマリ コンテナーとして 1 つのレポート ビューアーを使用しようとしています。これが私のコードです:
private void BaseForm_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'bgdataDataSet.FoodTable' table. You can move, or remove it, as needed.
this.FoodTableTableAdapter.Fill(this.bgdataDataSet.FoodTable);
BindingList<Data> _comboItems = new BindingList<Data>();
_comboItems.Add(new Data { Name = "Select", RptValue = "Select" });
_comboItems.Add(new Data { Name = "All Food Values", RptValue = "AllFoodValues.rdlc" });
_comboItems.Add(new Data { Name = "All Readings", RptValue = "AllReadings.rdlc" });
_comboItems.Add(new Data { Name = "Avg Food Values by Date", RptValue = "AvgFoodValuesByDate.rdlc" });
_comboItems.Add(new Data { Name = "Avg Food Values by Meal", RptValue = "AvgFoodValuesByMeal.rdlc" });
_comboItems.Add(new Data { Name = "Avg Readings by Date", RptValue = "AvgReadingsByDate.rdlc" });
_comboItems.Add(new Data { Name = "Avg Readings by Time", RptValue = "AvgReadingsByTime.rdlc" });
_comboItems.Add(new Data { Name = "Avg Readings by Event", RptValue = "AvgReadingsByEvent.rdlc" });
_comboItems.Add(new Data { Name = "Blood Pressure Chart", RptValue = "BPChart.rdlc" });
_comboItems.Add(new Data { Name = "Blood Pressure Report", RptValue = "BPReport.rdlc" });
_comboItems.Add(new Data { Name = "Detailed Food Values by Meal", RptValue = "DetailFoodValuesByMeal.rdlc" });
_comboItems.Add(new Data { Name = "Doctor Detailed Report", RptValue = "DoctorDetailedReport.rdlc" });
_comboItems.Add(new Data { Name = "Food Chart", RptValue = "FoodChart.rdlc" });
_comboItems.Add(new Data { Name = "Pumper Detail Report", RptValue = "PumperDetailReport.rdlc" });
_comboItems.Add(new Data { Name = "Reading Charts", RptValue = "ReadingCharts.rdlc" });
_comboItems.Add(new Data { Name = "Total Daily Food Intake", RptValue = "TotalIntakeDailyFood.rdlc" });
comboBox1.DataSource = _comboItems;
comboBox1.DisplayMember = "Name";
comboBox1.ValueMember = "RptValue";
comboBox1.SelectedValue = "Select";
this.rvDoctorReportViewer.RefreshReport();
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.SelectedIndex > 0)
{
string strReport;
strReport = "ReportViewer." + comboBox1.SelectedValue.ToString();
rvDoctorReportViewer.Reset();
rvDoctorReportViewer.LocalReport.ReportPath = "Reports/" + comboBox1.SelectedValue.ToString() + "";
rvDoctorReportViewer.LocalReport.ReportEmbeddedResource = strReport;
rvDoctorReportViewer.RefreshReport();
}
コードのブロック private voidomboBox1 のどこかでこれを指定できると考えていますが、その方法はわかりません。どんなアドバイスでも大歓迎です!