DataGridView RichTextBox行高问题

时间:2013-06-10 16:34:37

标签: c# datagridview

我在DataGridView中添加了一个RichTextBox列。

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

我也试过

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

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

2 个答案:

答案 0 :(得分:1)

您可以使用CellPainting事件更改它

private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
        {
            if (e.RowIndex != -1)
            {
                dataGridView1.Rows[e.RowIndex].Height = 100;
            }
        }

你好再次,关于你的要求,我认为这就是你想要的......

dataGridView1.Rows[e.RowIndex].Height = dataGridView1.Columns.GetFirstColumn(DataGridViewElementStates.Displayed).Width;

或...因为我们假设至少有一列存在......

dataGridView1.Rows[e.RowIndex].Height = dataGridView1.Columns[0].Width;

答案 1 :(得分:0)

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

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

点击RowTemplate右侧的箭头,显示更多细节;

编辑高度属性。