【问题标题】:C# - Get the sum of the total amount of width for each column in datagridviewC# - 获取datagridview中每一列的总宽度之和
【发布时间】:2018-01-22 13:36:35
【问题描述】:

除了循环遍历每一列并用它们的宽度增加一个变量之外,还有什么更快的方法吗?

目前这是最好的解决方案,但速度很慢:

int contentWidth = 0;
foreach (DataGridViewColumn column in grid.Columns) {
    contentWidth += column.Width;
}

【问题讨论】:

  • 你为什么不赞成我的回答?
  • @KamikyIT 我没有。

标签: c# datagridview sum width


【解决方案1】:

这将返回可见列的长度:

contentWidth = grid.Columns.GetColumnsWidth(DataGridViewElementStates.Displayed);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-30
    • 2013-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-24
    相关资源
    最近更新 更多