In this blog I will discuss one of the scenario often asked by the customers.
The requirement is to replace the default TextBox from the Parameter dialog with a DropDown. This drop-down would be bound to one of the columns of the datatable and hence the user can select any value from this drop-down that would be passed as a parameter to the report.
In order to achieve the above-mentioned scenario, the approach is to hide the default parameter dialog and show your own custom Parameter Dialog. For this you need to follow the under-mentioned steps :
1. Disable the default parameters dialog by adding the following line of code under the ‘InitializeParametersDialog’ event of the C1Report :
e.ShowDialog = False
This will not show the parameters dialog at the time of rendering of the report.
2. Here you can create your own Parameter Dailog with the DropDown and then display it using the ShowDialog method of the respective dailog/form
3. Once the dialog is shown and the value is selected by the user, the same can be saved in a variable.
4. Use this value and pass it to the report via the Report’s RecordSource property.
Dim frm As New Form2
Dim combo As New ComboBox
combo = DirectCast(frm.Controls("ComboBox2"), ComboBox)
str = combo.SelectedValue
C1Report1.DataSource.RecordSource = "SELECT * FROM Orders WHERE Orders.CustomerID= " + """" + str + """"
5. Render and display the report.
You may download the sample for complete implementation.