首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

vb.net怎么向水晶报表传递参数

2012-02-01 
vb.net如何向水晶报表传递参数?我设计了一个窗口,有两个datetimepicker,现想点击button1把这两时间分别传

vb.net如何向水晶报表传递参数?
我设计了一个窗口,有两个datetimepicker,现想点击button1把这两时间分别传递给水晶报表的两个时间参数
我用CrystalReport1.Parameter_date1.CurrentValues=datetimerpicker1.value.date
出错说CrystalReport1.Parameter_date1.CurrentValues是ReadOnly
怎样把参数传过去

[解决办法]
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared


Public Sub ConfigureDiscreteParameter(ByVal Report As ReportDocument, ByVal Field As String, ByVal Value As Object)
Dim myParameterFields As ParameterFields = Report.ParameterFields
Dim myParameterField As ParameterField = myParameterFields(Field)
Dim myParameterDiscreteValue As ParameterDiscreteValue = New ParameterDiscreteValue()
myParameterDiscreteValue.Value = Value
myParameterField.CurrentValues.Add(myParameterDiscreteValue)
End Sub


Public Sub ConfigureRangeParameter(ByVal Report As ReportDocument, ByVal Field As String, ByVal ValueStart As Object, ByVal ValueEnd As Object)
Dim myParameterFields As ParameterFields = Report.ParameterFields
Dim myParameterField As ParameterField = myParameterFields(Field)
Dim myParameterRangeValue As ParameterRangeValue = New ParameterRangeValue()
myParameterRangeValue.StartValue = ValueStart
myParameterRangeValue.EndValue = ValueEnd
myParameterField.CurrentValues.Add(myParameterRangeValue)
End Sub

给你两个以前写好的函数吧,第一个是离散参数,第二个是范围参数。

热点排行