stretch rows to fill entire height in DataGridView c# winform
<p>I'm learning a bit on <code>DataGridView</code></p>

<p>I have a <code>DataGridView</code> that I fill with some columns and row from <code>DataSource</code></p>

<p>later I want output a bitmap , for it i want that my columns and rows <strong>fill entire available space</strong> </p>

<p>with columns, I just use (it works fine)</p>

<pre><code>foreach (DataGridViewColumn col in DG_dataGridView.Columns)
{
    col.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
</code></pre>

<p><strong>My problem</strong> that I didn't able to do the same with rows </p>

<p>this my code</p>

<pre><code>//columns stretching
foreach (DataGridViewColumn col in DG_dataGridView.Columns)
{
    col.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}

var printSet = printDocument1.DefaultPageSettings;
DG_dataGridView.Height = printSet.Bounds.Height;

int headerHeight = DG_dataGridView.ColumnHeadersHeight;
int height = DG_dataGridView.Size.Height - headerHeight;
int rowHeight = height / DG_dataGridView.RowCount; // -1;

//rows stretching
for (int i = 0; i &lt; DG_dataGridView.Rows.Count; i++)
{
    DG_dataGridView.Rows[i].Height = rowHeight;
}

Bitmap bm = new Bitmap(DG_dataGridView.Width, DG_dataGridView.Height);

DG_dataGridView.DrawToBitmap(bm, new Rectangle(0, 0, DG_dataGridView.Width, DG_dataGridView.Height));

bm.Save(System.IO.Directory.GetCurrentDirectory() + @"\latestBitTable.bmp");
</code></pre>