[英]DirectCast how to implement
i am using code to the value textbox2.text in the report and using the code like below 我正在使用代码到报表中的值textbox2.text并使用如下代码
DirectCast(GL2.Section1.ReportObjects("txtfrmDt"), CrystalDecisions.CrystalReports.Engine.TextObject).Text = TextBox2.Text
the textbox2 take various values in run time but when i run the code it display only the final value intermediated values are not displayed the whole situation is as follows textbox2在运行时采用各种值,但是当我运行代码时,它仅显示最终值,中间值不显示,整个情况如下
bdcon.Open()
Dim QueryString1 As String
Dim QueryString2 As String
Dim y As Integer
y = ComboBox1.Items.Count
If ComboBox1.Text = "" Then
Dim dsf As DataSet = New DataSet()
For index As Integer = 0 To y - 1
Dim Cmd As New SqlCommand("select acname,amt,pamt,newdt from tr_cashbook where newdt BETWEEN @date1 AND @date2 AND acname='" + ComboBox1.Items.Item(index) + "' ORDER BY acname ASC,newdt ASC", bdcon)
Cmd.Parameters.Add("@date1", SqlDbType.DateTime).Value = DateTimePicker1.Value
Cmd.Parameters.Add("@date2", SqlDbType.DateTime).Value = DateTimePicker2.Value
Dim Adapter As SqlDataAdapter = New SqlDataAdapter(Cmd)
Dim ds As DataSet = New DataSet()
If (index = 0) Then
dsf = ds
Adapter.Fill(dsf, "Tr_Cashbook")
Else
dsf.Merge(ds, True)
Adapter.Fill(dsf, "Tr_Cashbook")
End If
If (index = y - 1) Then
Adapter.Fill(dsf, "Tr_Cashbook")
Ad.Fill(opd, "temp")
GL2.Load()
GL2.SetDataSource(dsf)
GL2.SetDataSource(opd)
CrystalReportViewer1.ReportSource = GL2
End If
QueryString1 = "select SUM(amt) as a, SUM(pamt) as b from tr_cashbook where newdt <='" + DateTimePicker1.Value + "'and acname ='" + ComboBox1.Items.Item(index) + "'"
Dim mycommand As New SqlCommand(QueryString1, bdcon)
MyReader = mycommand.ExecuteReader()
While MyReader.Read
If IsDBNull(MyReader("a")) Then
TextBox4.Text = "0.00"
Else
TextBox4.Text = MyReader("a")
End If
If IsDBNull(MyReader("b")) Then
TextBox5.Text = "0.00"
Else
TextBox5.Text = MyReader("b")
End If
TextBox8.Text = TextBox5.Text - TextBox4.Text
DirectCast(GL2.Section2.ReportObjects("T3"), CrystalDecisions.CrystalReports.Engine.TextObject).Text = TextBox5.Text//code this not working
End While
MyReader.Close()
Next
CrystalReportViewer1.ReportSource = GL2
you should do it like this: 您应该这样做:
add this on top of your code 将此添加到您的代码之上
Imports CrystalDecisions.CrystalReports.Engine
then 然后
Dim objText As TextObject = CType(rptFile.ReportDefinition.Sections(2).ReportObjects("T3"), TextObject)
objText.Text = "VALUE HERE"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.