首页 > 技术文章 > WINFORM DataGridView样式的继承优先级

sunlyk 2017-09-05 09:38 原文

样式继承
每个 DataGridViewCell 从其 InheritedStyle 属性获取外观。此属性返回的 DataGridViewCellStyle 对象从类型 DataGridViewCellStyle 的属性层次结构继承其属性值。下面按非标头单元格的 InheritedStyle 获取其值的顺序列出这些属性。 
1. System.Windows.Forms.DataGridViewCell.Style  
2. System.Windows.Forms.DataGridViewRow.DefaultCellStyle  
3. System.Windows.Forms.DataGridView.AlternatingRowsDefaultCellStyle(仅限于索引号为奇数的行中的单元格) 
4. System.Windows.Forms.DataGridView.RowsDefaultCellStyle  
5. System.Windows.Forms.DataGridViewColumn.DefaultCellStyle  
6. System.Windows.Forms.DataGridView.DefaultCellStyle  
注:数字越大,优先级越高。
MSDN

推荐阅读