DataGridViewCell.HasStyle DataGridViewCell.HasStyle DataGridViewCell.HasStyle DataGridViewCell.HasStyle Property


获取指示是否已设置 Style 属性的值。Gets a value indicating whether the Style property has been set.

 property bool HasStyle { bool get(); };
public bool HasStyle { get; }
member this.HasStyle : bool
Public ReadOnly Property HasStyle As Boolean


如果已设置 Style 属性,则为 true;否则为 falsetrue if the Style property has been set; otherwise, false.


获取的值Style属性自动实例化新DataGridViewCellStyle如果以前未访问属性。Getting the value of the Style property automatically instantiates a new DataGridViewCellStyle if the property has not previously been accessed. 因此,必须使用HasStyle属性来确定是否Style属性当前设置为DataGridViewCellStyle实例。Therefore, you must use the HasStyle property to determine whether the Style property is currently set to a DataGridViewCellStyle instance. 此操作可用于确定对象的哪些属性由返回InheritedStyle属性表示专门为该单元格设置样式。This is useful to determine which properties of the object returned by the InheritedStyle property represent styles set specifically for the cell.

有关单元格的样式继承的详细信息,请参阅Windows 窗体 DataGridView 控件中的单元格样式For more information about cell style inheritance, see Cell Styles in the Windows Forms DataGridView Control.