我正在尝试更改包含“修改”单词的
我用
我对
DataGrid
单元格的Background
颜色。
在WinForms
中,我使用以下代码实现了这一点:
DataGridViewCellStyle style = new DataGridViewCellStyle();
style.BackColor = Color.DarkCyan;
foreach (DataGridViewRow Row in dataGridView1.Rows)
{
if (Row.Cells["Permission"].Value.ToString().Contains("Modify"))
{
Row.Cells["Permission"].Style = style;
}
}
我用
DataTable
填充这个DataGrid
。我对
WPF
了解很少,如果你有任何建议,请具体说明。
dataGrid1.ItemsSource = dataTable.AsDataView();
来获取 DataTable,但是我收到了消息“在使用 ItemSource 之前,项集合必须为空”。 - Paulo Rocha