如何在VB中将DataGridView的选定行打印到Printdocument

时间:2017-04-05 00:54:55

标签: vb.net printing datagridview

我尝试将所有选定的行从Form1上的Datagridview打印到Form2上的Printdocument。

    Private Sub PrintDocument1_PrintPage(sender As System.Object, e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage

    Dim fon As New Font(FontFamily.GenericSansSerif, 12, FontStyle.Regular)

    e.Graphics.DrawString(Detalle_Editar.CODIGO.HeaderText, fon, Brushes.Black, 300, 200)

    Dim ce = Detalle_Editar.Detalle_VDataGridView.CurrentCell.RowIndex

    e.Graphics.DrawString(Detalle_Editar.Detalle_VDataGridView.Item(Detalle_Editar.CODIGO.HeaderText, ce).Value.ToString, fon, Brushes.Black, 300, 200)

End Sub

当我运行代码时,我得到" objet引用未设置为对象的实例"在这一行:

Dim ce = Detalle_Editar.Detalle_VDataGridView.CurrentCell.RowIndex

你有解决方案吗? 谢谢!

0 个答案:

没有答案