my code is
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
int height = 0;
int width = 0;
Pen p = new Pen(Brushes.Black, 2.5f);
#region Invoice
e.Graphics.FillRectangle(Brushes.DarkGray, new Rectangle(25,25, dataGridView1.Columns[0].Width, dataGridView1.Rows[0].Height));
e.Graphics.DrawRectangle(p, new Rectangle(25,25, dataGridView1.Columns[0].Width, dataGridView1.Rows[0].Height));
e.Graphics.DrawString(dataGridView1.Columns[0].HeaderText.ToString(), dataGridView1.Font, Brushes.Black, new Rectangle(25,25, dataGridView1.Columns[0].Width, dataGridView1.Rows[0].Height));
#endregion
#region name
e.Graphics.FillRectangle(Brushes.DarkGray, new Rectangle(5 + dataGridView1.Columns[0].Width, 10, dataGridView1.Columns[0].Width, dataGridView1.Rows[0].Height));
e.Graphics.DrawRectangle(p, new Rectangle(10 + dataGridView1.Columns[0].Width, 10, dataGridView1.Columns[0].Width, dataGridView1.Rows[0].Height));
e.Graphics.DrawString(dataGridView1.Columns[1].HeaderText.ToString(), dataGridView1.Font, Brushes.Black, new Rectangle(10 + dataGridView1.Columns[0].Width, 10, dataGridView1.Columns[0].Width, dataGridView1.Rows[0].Height));
#endregion
}
What I have tried:
I had tried many values instead of 25