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; }
[<System.ComponentModel.Browsable(false)>]
member this.HasStyle : bool
Public ReadOnly Property HasStyle As Boolean

属性值

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.

适用于

另请参阅