Click here to Skip to main content
15,908,015 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Good morning all!

I've got a problem that I'd like some help with. I am building a Winforms desktop application (c#) and I'm trying to populate a combobox with some reports I've built (inside of VS). On my form I have three controls, one combobox cboReports, one button btnViewReport and one report viewer reportViewer. I am trying to populate the cboReports with reports I've created. Upon selecting a report the user will click btnViewReport and the selected report will fill reportViewer report view.

this.reportViewer.RefreshReport();
    }

    private class Data
    {
        public string Name { get; set; }
        public string RptValue { get; set; }
    }



    public string strReport { get; set; }

    private void cboReports_SelectedIndexChanged(object sender, EventArgs e)
    {

        BindingList<Data> _comboItems = new BindingList<Data>();
        _comboItems.Add(new Data { Name = "Select", RptValue = "Select a report" });
        _comboItems.Add(new Data { Name = "CJ01_DateRange", RptValue = "CJ01_DateRange.rdlc" });

        cboReports.DataSource = _comboItems;
        cboReports.DisplayMember = "Name";
        cboReports.ValueMember = "RptValue";

        strReport = "ReportViewer." + cboReports.SelectedValue;

    }


This is what I have so far. Can someone help please?
Posted
Comments
ZurdoDev 6-Mar-14 9:49am    
Where are you stuck exactly?
Branden Coker 6-Mar-14 10:55am    
My apologies I should have specified. I don't have anything populated in my combobox. I have one report as of now in my project "CJ01_DateRange.rdlc" that won't show up in my combobox. I'm just doing a bunch of guess work here I'm not even sure if it is possible to load a file from the combobox.
ZurdoDev 6-Mar-14 11:01am    
I still don't know what your question is.
Branden Coker 6-Mar-14 11:29am    
How do I display the reports I've created in the combobox and then run those reports in my report viewer on button click?
ZurdoDev 6-Mar-14 11:35am    
Display is easy. Just add the list to the combobox.

The report viewer has properties (I haven't used it before so I am not sure what they are) to load the rdl file.

So, when the combobox selected index changes just set the report viewers rdl to the one they picked.

1 solution

Based on the comments, it appears you are really looking for general direction on how to do this.

Essentially you just need to add your list of reports to your combobox, and just do that manually.

Then when the selected index changes just change the rdl that your report viewer is using to be the one they changed.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900