Private Function SetupThePrinting() As Boolean
If Me.CheckBox18.Checked = False And Me.CheckBox19.Checked = False And Me.CheckBox20.Checked = False And Me.CheckBox21.Checked = False Then Exit Function
Dim MyPrintDialog As PrintDialog = New PrintDialog()
MyPrintDialog.AllowCurrentPage = False
MyPrintDialog.AllowPrintToFile = False
MyPrintDialog.AllowSelection = False
MyPrintDialog.AllowSomePages = True
MyPrintDialog.PrintToFile = False
MyPrintDialog.ShowHelp = False
MyPrintDialog.ShowNetwork = False
If MyPrintDialog.ShowDialog() <> System.Windows.Forms.DialogResult.OK Then Return False
PrintDocument1.DocumentName = "Customers Report"
PrintDocument1.PrinterSettings = MyPrintDialog.PrinterSettings
PrintDocument1.DefaultPageSettings = MyPrintDialog.PrinterSettings.DefaultPageSettings
If Me.CheckBox18.Checked = True Then
Me.DataGridView1.EnableHeadersVisualStyles = False 'this line is neccesry to make the second line work.
Me.DataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.White
Dim FontBold As New Font(DataGridView1.ColumnHeadersDefaultCellStyle.Font, FontStyle.Bold)
Me.DataGridView1.ColumnHeadersDefaultCellStyle.Font = FontBold
'Dim FontSize As New Font(DataGridView1.ColumnHeadersDefaultCellStyle.Font.Size, 20)
'Me.DataGridView1.ColumnHeadersDefaultCellStyle.Font = FontSize
If MessageBox.Show("Do you want the report to be centered on the page", "InvoiceManager - Center on Page", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
DataGridView1Printer = New DataGridViewPrinter(DataGridView1, PrintDocument1, True, True, Form6.RichTextBox1.Text, New Font("Tahoma", 18, FontStyle.Bold, GraphicsUnit.Point), Color.Black, True)
Else
DataGridView1Printer = New DataGridViewPrinter(DataGridView1, PrintDocument1, False, True, Form6.RichTextBox1.Text, New Font("Tahoma", 18, FontStyle.Bold, GraphicsUnit.Point), Color.Black, True)
End If
End If
If Me.CheckBox19.Checked = True Then
Me.DataGridView2.EnableHeadersVisualStyles = False 'this line is neccesry to make the second line work.
Me.DataGridView2.ColumnHeadersDefaultCellStyle.BackColor = Color.White
Dim FontBold As New Font(DataGridView1.ColumnHeadersDefaultCellStyle.Font, FontStyle.Bold)
Me.DataGridView2.ColumnHeadersDefaultCellStyle.Font = FontBold
If MessageBox.Show("Do you want the report to be centered on the page", "InvoiceManager - Center on Page", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
DataGridView1Printer = New DataGridViewPrinter(DataGridView2, PrintDocument1, True, True, Form6.RichTextBox1.Text, New Font("Tahoma", 18, FontStyle.Bold, GraphicsUnit.Point), Color.Black, True)
Else
DataGridView1Printer = New DataGridViewPrinter(DataGridView2, PrintDocument1, False, True, Form6.RichTextBox1.Text, New Font("Tahoma", 18, FontStyle.Bold, GraphicsUnit.Point), Color.Black, True)
End If
End If
If Me.CheckBox20.Checked = True Then
Me.DataGridView4.EnableHeadersVisualStyles = False 'this line is neccesry to make the second line work.
Me.DataGridView4.ColumnHeadersDefaultCellStyle.BackColor = Color.White
Dim FontBold As New Font(DataGridView1.ColumnHeadersDefaultCellStyle.Font, FontStyle.Bold)
Me.DataGridView4.ColumnHeadersDefaultCellStyle.Font = FontBold
If MessageBox.Show("Do you want the report to be centered on the page", "InvoiceManager - Center on Page", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
DataGridView1Printer = New DataGridViewPrinter(DataGridView4, PrintDocument1, True, True, Form6.RichTextBox1.Text, New Font("Times New Roman", 14, FontStyle.Regular, GraphicsUnit.Point), Color.Black, True)
Else
DataGridView1Printer = New DataGridViewPrinter(DataGridView4, PrintDocument1, False, True, Form6.RichTextBox1.Text, New Font("Times New Roman", 14, FontStyle.Regular, GraphicsUnit.Point), Color.Black, True)
End If
End If
If Me.CheckBox21.Checked = True Then
Me.DataGridView3.EnableHeadersVisualStyles = False 'this line is neccesry to make the second line work.
Me.DataGridView3.ColumnHeadersDefaultCellStyle.BackColor = Color.White
Dim FontBold As New Font(DataGridView1.ColumnHeadersDefaultCellStyle.Font, FontStyle.Bold)
Me.DataGridView3.ColumnHeadersDefaultCellStyle.Font = FontBold
If MessageBox.Show("Do you want the report to be centered on the page", "InvoiceManager - Center on Page", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
DataGridView1Printer = New DataGridViewPrinter(DataGridView3, PrintDocument1, True, True, Form6.RichTextBox1.Text, New Font("Times New Roman", 14, FontStyle.Regular, GraphicsUnit.Point), Color.Black, True)
Else
DataGridView1Printer = New DataGridViewPrinter(DataGridView3, PrintDocument1, False, True, Form6.RichTextBox1.Text, New Font("Times New Roman", 14, FontStyle.Regular, GraphicsUnit.Point), Color.Black, True)
End If
End If
Return True
End Function