【问题标题】:How can i display all current rows from datagridview in crystal report using vb.net如何使用 vb.net 在水晶报表中显示 datagridview 中的所有当前行
【发布时间】:2013-06-16 16:41:09
【问题描述】:

我的 datagridview 和水晶报表有小问题

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

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

我的代码

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

这是我的申请流程

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

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

这里发生了什么

首先我点击了datagridview中的ON Row

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

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

【问题讨论】:

    标签: vb.net datagridview crystal-reports


    【解决方案1】:

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

    更改crystal.SetDataSource(TABLE)

    crystal.SetDataSource(DataGridView1.Datasource)

    【讨论】:

    • matzone 我试过你的代码,但没有用,它只显示一行而不是所有当前行
    • @user2491058 .. 对不起,误解了 .. 你的意思是你想在 datagridview 中打印所有选定的行?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多