风的DataGridViewCell和派生类获取或设置在细胞水平上指定的样式。这些样式覆盖上级继承的。
InheritedStyle的DataGridViewCell,的DataGridViewRow,DataGridViewColumn和派生类获取所有的风,包括从上级继承样式应用到当前单元,行或列。
如上所述,得到了一个样式属性的会自动实例化一个新的DataGridViewCellStyle对象如果属性尚未以前设置。为了避免不必要地创建这些对象,行和列类有一个HasDefaultCellStyle属性,您可以检查以确定是否DefaultCellStyle属性已设置。同样,细胞类具有HasStyle属性,指示是否Style属性已设置。
每个属性的样式上有一个相应的PropertyNameChanged DataGridView控件的事件。对于行,列和单元属性,事件名称开头“行”,“列”,或“细胞”(例如,RowDefaultCellStyleChanged)。这些事件发生时,每一个对应的样式属性设置为不同的DataGridViewCellStyle对象。这些事件不会发生当您检索从样式属性的DataGridViewCellStyle对象,并修改其属性。为了应对变化的单元样式对象本身,处理CellStyleContentChanged事件。
5.1.3样式继承
每个DataGridViewCell的会从它的InheritedStyle属性它的外观。 DataGridViewCellStyle对象的此属性返回继承从类型DataGridViewCellStyle的属性层次的价。下面列出了这些属性的顺序在其中非头细胞InheritedStyle获取其。
1。 DataGridViewCell.Style
2。 DataGridViewRow.DefaultCellStyle
3。 AlternatingRowsDefaultCellStyle(只适用于奇数行单元指数)
4。 RowsDefaultCellStyle
5。 DataGridViewColumn.DefaultCellStyle
6。的DefaultCellStyle
对于行和列标题单元,InheritedStyle属性填充的是从给定的顺序在下面的列表源属性。
1。 DataGridViewCell.Style
2。 ColumnHeadersDefaultCellStyle或RowHeadersDefaultCellStyle
3。的DefaultCellStyle
下图演示了这个过程。
您还可以通过特定的行和列继承的样式。列InheritedStyle财产继承了以下属性的。
1。 DataGridViewColumn.DefaultCellStyle
2。的DefaultCellStyle
该行InheritedStyle财产继承了以下属性的。
1。 DataGridViewRow.DefaultCellStyle
2。 AlternatingRowsDefaultCellStyle(只适用于奇数行单元指数)
3。 RowsDefaultCellStyle
4。的DefaultCellStyle
对于每一个由InheritedStyle属性返回一个DataGridViewCellStyle对象属性,属性是从第一个单元样式列表,在适当的相应的属性设置为除DataGridViewCellStyle类的默认等。
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/tongxinshuyu/article-50070-28.html
好想去哎谁让我是个学生党呢凡凡
一个浙江财经学院教授在研究问题时就只有一个3000万的推测数据吗