【问题标题】:DataGridViewRichTextBox row height issueDataGridView RichTextBox 行高问题
【发布时间】:2013-06-10 16:34:36
【问题描述】:

我正在我的 DataGridView 中添加一个 RichTextBox 列。

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

我也试过

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

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

【问题讨论】:

  • 那么你需要改变行高吗?

标签: c# datagridview


【解决方案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;

【讨论】:

  • hi..这工作正常,但我想根据宽度更改行高或图像高度。
  • 嗨 Nitesh 我编辑了 2 种可能性,说明我认为你想要什么
【解决方案2】:

如果你想在设计时设置它:

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

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

编辑高度属性。

【讨论】:

    猜你喜欢
    • 2022-01-14
    • 1970-01-01
    • 2013-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多