如何使用 vb.net 在水晶报告中显示 datagridview 中的所有当前行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17135478/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 13:55:52  来源:igfitidea点击:

How can i display all current rows from datagridview in crystal report using vb.net

vb.netdatagridviewcrystal-reports

提问by cicor

I have small issue with my datagridview and crystal report

我的数据网格视图和水晶报告有小问题

I am using this code for display my crystal report but my problem is i can display only one row from data grid view

我正在使用此代码显示我的水晶报告,但我的问题是我只能从数据网格视图中显示一行

I want to print all rows from datagridview in crystal report

我想在水晶报表中打印 datagridview 中的所有行

MY CODE

我的代码

Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    Dim SqlQuery As String = "SELECT * FROM BMS_APP WHERE SN = " & BMS_APP.DataGridView1.SelectedRows(0).Cells(0).Value.ToString() & ""
    Dim SqlCommand As New OleDbCommand
    Dim SqlAdepter As New OleDbDataAdapter
    Dim TABLE As New DataTable

    With SqlCommand
        .CommandText = SqlQuery
        .Connection = BMS_APP.cnn
    End With
    With SqlAdepter
        .SelectCommand = SqlCommand
        .Fill(TABLE)
    End With
    Dim crystal As New CrystalReport1
    crystal.SetDataSource(TABLE)
    CrystalReportViewer1.ReportSource = crystal
    CrystalReportViewer1.Refresh()
End Sub

Here Is My Process Of Application

这是我的申请流程

I have clicked on load button and it loads all data from database to datagridview

我点击了加载按钮,它将所有数据从数据库加载到 datagridview

After that when i click on particular row its display only one row in crystal report but i want to display all current rows which was in datagriwview

之后,当我单击特定行时,它在水晶报表中仅显示一行,但我想显示 datagriwview 中的所有当前行

Here What's Happen

这里发生了什么

First I have Clicked ON Row in datagridview

首先,我在 datagridview 中单击了 ON Row

It shows in crystal report one row but i want to print all rows current rows

它在水晶报告中显示一行,但我想打印当前行的所有行

Please Help what should i do print all current rows thank you

请帮助我应该怎么做打印所有当前行谢谢

采纳答案by matzone

If you want to print all records in your DGV ..

如果要打印 DGV 中的所有记录..

change crystal.SetDataSource(TABLE)

改变 crystal.SetDataSource(TABLE)

to crystal.SetDataSource(DataGridView1.Datasource)

crystal.SetDataSource(DataGridView1.Datasource)