[英]C# DataGridView Row add dataGridView button text not change
[英]Change textcolor of a row in a datagridview if a cell contains part of text c#
如果该行中的某个单元格包含一些文本,则如何更改整个行的原色?
我有这样的代码,但它只会更改包含确切单词的单元格的颜色。
private void constringview_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (e.Value != null && e.Value.ToString() == "838")
{
e.CellStyle.ForeColor = Color.BlueViolet;
}
}
如果单元格包含单词的一部分,我想给整行着色
您可以通过以下方式获取行索引形式DataGridViewCellFormattingEventArgs来访问行
private void constringview_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (e.Value != null && e.Value.ToString() == "838")
{
dataGridView1.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.BlueViolet;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.