上周在开发Winform 项目中,我曾遇到一个看似简单,但一直都没有解决的问题,那就是:设置winform DataGridView控件的行DefaultCellStyle,但却没有任何变化,我也曾求助于博问:http://q.cnblogs.com/q/72294/,但大家给的 ...
上周在开发Winform 项目中,我曾遇到一个看似简单,但一直都没有解决的问题,那就是:设置get='_blank'>winform DataGridView控件的行DefaultCellStyle,但却没有任何变化,我也曾求助于博问:http://q.cnblogs.com/q/72294/,但大家给的答案没有一个能解决这个问题,可能是问题重现不太容易,我自己也曾多次在其它项目中尝试重现这个问题,但一直都是正确的,没有出现我当前项目的问题,简直要崩溃啊!
先来看看我原有的代码:
private void Form1_Load(object sender, EventArgs e) { dataGridView1.SetHeader<Zwj.TEMS.Entities.AssetDetail>(t => t.AssetSingleNo, t => t.BaseInfo.Name, t => t.BaseInfo.Category.CategoryName, t => t.Price, t => t.ProcureImport.Date, t => t.State.State); LoadData(); } private void LoadData() { var resultList = QueryBusiness<ProcureExport>.GetList(t =>true,//这里演示就直接忽略条件 t => new { t.AssetSingleNo, t.AssetSingleInfo.BaseInfo.Name, t.AssetSingleInfo.BaseInfo.Category.CategoryName, t.AssetSingleInfo.Price, t.AssetSingleInfo.ProcureImport.Date, t.AssetSingleInfo.State.State },t =>t.AssetSingleNo,1,10); dataGridView1.DataSource = resultList; int entityInListIndex = 1; dataGridView1.Rows[entityInListIndex].DefaultCellStyle = new DataGridViewCellStyle() { ForeColor = Color.Blue, Font = new Font("Arial", 11F, FontStyle.Bold) }; }
海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com
原标题:关于C# Winform DataGridView 设置DefaultCellStyle无效的原因与解决方案
关键词:C#
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。