datagridview如何改变选中行的背景颜色?如何在C#Windows应用程序中更改datagridview选定行的背景颜色?在DataGridView上有一个DefaultCellStyle,它具有SelectionBackColor和SelectionForeColor属性。DataGridView使用样式继承的想法,以防您发现未选择的样式:http://msdn.microsoft.com/en-us/library/1yef90x0.aspx来吧,伙计......必须有一个简单的解决方案,终于拿到了dataGridView1.DefaultCellStyle.SelectionBackColor=Color.Blue;dataGridView1.DefaultCellStyle.SelectionForeColor=Color.Red;这对我有用,没有复杂的代码,没有事件处理。我以前做过这个,但不记得所以认为发布它会在未来帮助其他人和我:)利用DataGridViewCell的事件CellEnter和CellLeave你可以尝试这样的事情:fooCellStyle=newDataGridViewCellStyle();fooCellStyle.BackColor=System.Drawing.Color.LightYellow;this.VariableFinderDataGridView.CurrentCell.Style.ApplyStyle(fooCellStyle);}privatevoidfoobarFinderDataGridView_CellLeave(objectsender,DataGridViewCellEventArgse){DataGridViewCellStylebarCellStyle=newDataGridViewCellStyle();barCellStyle.BackColor=System.Drawing.Color.White;this.VariableFinderDataGridView.CurrentCell.Style.ApplyStyle(barCellStyle);}这是我的代码以上是C#学习教程:如何改变datagridview中选中行的背景色?如果分享的所有内容对你有用,需要了解更多C#学习教程,希望你多多关注~。栗色;dataGridView1.CurrentRow.DefaultCellStyle.ForeColor=Color.White;}本文收集自网络,不代表立场。如涉及侵权,请点击右侧联系管理员删除。如有转载请注明出处:
