Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何计算 dgv.Rows.Height
int x = dgv1.Rows.Height
Rows.Height 或 dgv1.RowsHeight 不存在。
行高可能会有所不同,因此请尝试您想要的行:
int x = dgv1.Rows[0].Height;
或者,我认为它也可以从模板中获得:
int x = dgv1.RowTemplate.Height;
如果您想要列标题和所有行的组合高度,请尝试:
int x = dgv1.ColumnHeadersHeight + dgv1.Rows.Cast<DataGridViewRow>().Sum(r => r.Height);