【问题标题】:DataGridView, How to use if statement for a cell that starts with a stringDataGridView,如何对以字符串开头的单元格使用 if 语句
【发布时间】:2015-05-13 15:00:48
【问题描述】:

我希望能够使用 if 语句来确定以字符串“Manual”开头的 DGV 单元格的颜色。我知道如何改变单元格的颜色

if (Convert.ToString(DGV_Points.Rows[x].Cells[2].Value.StartsWith) == "Manual")
                    {

                    }

还可以在单​​击标题时禁用单元格默认颜色的恢复吗?

【问题讨论】:

  • BackColor 在样式属性中:DGV_Points.Rows[x].Cells[2].Style.BackColor = Color.youNameIt; 恢复它是最有效的方式,它将修改后的单元格存储在 List 中,并在必要时循环遍历它..

标签: c# datagridview background-color cells


【解决方案1】:
if (DGV_Points.Rows[x].Cells[2].Value.ToString().StartsWith("Manual"))
{

}

这是你要找的吗?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-23
    • 2018-02-11
    相关资源
    最近更新 更多