我尝试将所有选定的行从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
你有解决方案吗? 谢谢!