我正在我的 DataGridView 中添加一个 RichTextBox 列。
在 DataGridView 中,行的 RichTextBox 高度是自动设置的。 并且文本显示不正确。 那么如何设置行高呢?
我也试过
datagridview1 row1=new datagridview();
row1.height=100;
但是行高没有设置好。 请给我建议。
最佳答案
您可以使用 CellPainting 事件更改它
private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.RowIndex != -1)
{
dataGridView1.Rows[e.RowIndex].Height = 100;
}
}
你好,nitesh,关于你的要求,我想这就是你想要的......
dataGridView1.Rows[e.RowIndex].Height = dataGridView1.Columns.GetFirstColumn(DataGridViewElementStates.Displayed).Width;
或者...因为我们假设至少存在 1 列...
dataGridView1.Rows[e.RowIndex].Height = dataGridView1.Columns[0].Width;
关于c# - DataGridView RichTextBox 行高问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17028709/