【问题标题】:how to increase rows size in DataGridView如何增加 DataGridView 中的行大小
【发布时间】:2011-07-05 17:42:55
【问题描述】:

如何使用 C# 增加 DataGridView 中的行大小?我找不到这个属性。

提前致谢。

【问题讨论】:

  • 您是在寻找行数还是每行的高度?
  • 如何增加size-height?宽度?您是想在标记中设置它,还是在代码隐藏中进行设置,或者动态响应事件或其他输入?

标签: c# .net winforms datagridview


【解决方案1】:

您始终可以遍历所有DataGridViewRows 并设置Height 属性:

foreach (DataGridViewRow row in dataGridView1.Rows) {
    if (heightShouldBeSet) {
        row.Height = yourHeightSetting;
    }
}

【讨论】:

  • @Gali 只通过我展示的 DataGridView 的 DataGridViewRowCollection。
【解决方案2】:

您需要添加一个新行。

int n = dataGridView1.Rows.Add();

dataGridView1.Rows[n].Cells[0].Value = title;
dataGridView1.Rows[n].Cells[1].Value = dateTimeNow;

【讨论】:

    【解决方案3】:

    如果您想增加行高,您也可以将空行连接到单元格值。

    【讨论】:

      猜你喜欢
      • 2014-02-13
      • 1970-01-01
      • 2016-07-02
      • 2016-04-23
      • 1970-01-01
      • 1970-01-01
      • 2012-11-07
      • 2012-12-21
      • 2011-12-23
      相关资源
      最近更新 更多