DataGridViewCell.HasStyle 属性

定义

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

public:
 property bool HasStyle { bool get(); };
[System.ComponentModel.Browsable(false)]
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 属性的值将自动实例化新的 DataGridViewCellStyleGetting 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.

适用于

另请参阅