2

我在 DataGridView 中添加了 RichTextBox 列。

在 DataGridView 中,行的 RichTextBox 高度是自动设置的。并且文本显示不正确。那么如何设置行高呢?

我也试过

datagridview1 row1=new datagridview();
row1.height=100;

但行高设置不正确。请给我建议。

4

2 回答 2

1

您可以使用 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;
于 2013-06-10T17:19:57.100 回答
0

如果您希望在设计时设置它:

在 DataGridView 的属性中,找到 RowTemplate 属性;

单击 RowTemplate 右侧的箭头,显示更多详细信息;

编辑高度属性。

于 2014-03-04T17:31:18.640 回答