您的位置:首页 > 其它

DataGrid中行背景色和字体颜色的设置

2010-03-02 16:58 399 查看
DataGrid加载事件:

private void dgvNotesManage_LoadingRow(object sender, DataGridRowEventArgs e)
{
try
{
DataRowView drv = e.Row.Item as DataRowView;
if (drv != null)
{
if (!drv["NoteCategory"].ToString().IsNullOrEmpty())
{
if (drv["NoteCategory"].ToString().Trim() == "重要")
{

e.Row.Foreground = new SolidColorBrush(Colors.Red);//前景色即字体的颜色
e.Row.Background = new SolidColorBrush(Colors.Red);//背景色
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);

}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐