Results 1 to 3 of 3

Thread: Using a Boolean-type parameter in an RDLC report

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Location
    San Francisco, CA
    Posts
    503

    Using a Boolean-type parameter in an RDLC report

    I have a WinForms report that uses a boolean-type parameter (flgShowAreaPlants). In the RDLC I've added the parameter and set its data type to "Boolean".

    Name:  2024-06-14_10-19-00.jpg
Views: 55
Size:  10.3 KB

    I add the parameter to the ReportViewer in the Load event of the report's form.

    The following code does not work...

    Code:
    myParam = New ReportParameter("flgShowAreaPlants", flgShowAreaPlants)
    ReportViewer1.LocalReport.SetParameters(myParam)
    The Error List window shows the following error.

    Error BC30518 Overload resolution failed because no accessible 'New' can be called with these arguments:
    'Public Overloads Sub New(name As String, value As String)': Option Strict On disallows implicit conversions from 'Boolean' to 'String'.
    'Public Overloads Sub New(name As String, values As String())': Value of type 'Boolean' cannot be converted to 'String()'.

    This code works...

    Code:
    myParam = New ReportParameter("flgShowAreaPlants", CStr(flgShowAreaPlants))
    ReportViewer1.LocalReport.SetParameters(myParam)
    Looking at the ReportParameter class, I see the 5 overload methods and 2 of them have a "visible As Boolean" property.

    Code:
    Namespace Microsoft.Reporting.WinForms
        Public NotInheritable Class ReportParameter
            Public Sub New()
            Public Sub New(name As String)
            Public Sub New(name As String, value As String)
            Public Sub New(name As String, values() As String)
            Public Sub New(name As String, value As String, visible As Boolean)
            Public Sub New(name As String, values() As String, visible As Boolean)
    
            Public Property Name As String
            Public Property Values As StringCollection
            Public Property Visible As Boolean
        End Class
    Using the 4th overload method works also...

    Code:
    myParam = New ReportParameter("flgShowAreaPlants", CStr(flgShowAreaPlants), True)
    ReportViewer1.LocalReport.SetParameters(myParam)
    The only documentation on the "visible As Boolean" property that I've found is not much help.

    https://learn.microsoft.com/en-us/pr...51861(v=vs.90)

    Why must a Boolean-type parameter be added to the ReportViewer as string-type? What is the purpose of the "visible As Boolean" property?

    Looking for some help to understand what is going on.
    Last edited by Mark@SF; Jun 14th, 2024 at 09:22 AM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,604

    Re: Using a Boolean-type parameter in an RDLC report

    My guess would be that the parameter values have to be text for transmission anyway, so can only be provided as text.

    As for the visible parameter, I think that means that the report viewer will display that parameter so the user can set it at run time.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Location
    San Francisco, CA
    Posts
    503

    Re: Using a Boolean-type parameter in an RDLC report

    Thank you, jmc.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width