private void button3_Click(object sender, EventArgs e) { int selectedRow = dgvHistoryOrder.CurrentCell.RowIndex; if (dgvHistoryOrder.Rows[selectedRow].Cells[0].Value == null) { MessageBox.Show("Hãy chọn hóa đơn bạn cần in!"); } else { string id = dgvHistoryOrder.Rows[selectedRow].Cells[0].Value.ToString(); billText = transactionDAL.GetBill(id); printPreviewDialog1.Document = printDocument2; printDocument2.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("pprnm", 300, 800); printPreviewDialog1.ShowDialog(); } }