简体   繁体   English

如何在datagridview中控制文本颜色

[英]how to control text color in datagridview

When I run my App first I fill my datagridview , then I loop over my rows and change the font color, everything works fine but when I sort my rows (clicking on the head of datagridview column) the font color is back to it's origin color. 当我首先运行我的应用程序时,我填充了datagridview ,然后循环遍历了行并更改了字体颜色,一切正常,但是当我对行进行排序(单击datagridview列的datagridview )时,字体颜色又回到了原始颜色。 After checking this subject I found about the attribute 'Default Cell Styles' - I need to know how to disable it on a specific column, I need my font color not to change. 在检查了此主题之后,我发现了有关“默认单元格样式”属性的信息-我需要知道如何在特定列上禁用它,我需要字体颜色不要更改。

CurrentCellChange Event allows you to provide new action once your datagridview 's cell has changed, so basically: 一旦datagridview的单元格发生更改,CurrentCellChange Event允许您提供新的操作,因此基本上:

private void DataGrid1_CurrentCellChanged(object sender, EventArgs e)
{

    //your style code

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM