且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

仅在水晶报表中打印选定的datagridview行

更新时间:2023-12-05 09:52:52

难道你不能再向SelectionForumla添加另一个条件,比如

Couldn''t you just add another condition to the SelectionForumla, like
{tblEmployee.Emp_No} = ''someValue'' OR {tblEmployee.Emp_No} = ''someOtherValue'' OR ...



并继续按要求添加。


and keep adding them as required.


Private Sub Button21_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button21.Click
        Dim i As New Integer
        Dim myparams As New ParameterFields
        Dim myparam As New ParameterField
        Dim rpt2 As New CrystalReport2()
        i = 0
        myparam.ParameterFieldName = "ids"

        For i = 0 To Me.DataGridView1.SelectedRows.Count - 1
            Dim myDiscreteValue As New ParameterDiscreteValue()
            myDiscreteValue.Value = System.Convert.ToInt32(Me.DataGridView1.SelectedRows(i).Cells(0).Value)
            myparam.CurrentValues.Add(myDiscreteValue)
            ' Add param object to params collection
            myparams.Add(myparam)
            Next i
        rpt2.SetDataSource(DataSet31)
        printmulti.CrystalReportViewer1.ReportSource = rpt2
        printmulti.CrystalReportViewer1.ParameterFieldInfo = myparams
        printmulti.CrystalReportViewer1.Refresh()
        printmulti.Show()
    End Sub



将此项添加到记录选择公式{Table_1.id} = {?ids}并选择(左ctrl + lmousebutton)多行,按代码按钮(button31_click),您可以打印多个记录。


add this to the record selection formula {Table_1.id} = {?ids} and select (left ctrl + lmousebutton) multiple rows, press the code button (button31_click) and you can print multiple records.