I want to make a dataGridView's size to fit the columns and rows total size. About total height, I managed to fit it to columns's height like that:
const int datagridLines = 30;
s.Height = dataGridView2.Columns[0].HeaderCell.Size.Height;
for (byte i = 0; i < datagridLines; i++)
{
dataGridView2.Rows.Add();
s.Height += dataGridView2.Rows[i].Height;
}
dataGridView2.ClientSize = s;
I tried some things to also fit the width but no luck. Any suggestions?
Thanks.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…