本文整理汇总了C#中System.Windows.Forms.DataGridViewCellStyle.ApplyStyle方法的典型用法代码示例。如果您正苦于以下问题:C# DataGridViewCellStyle.ApplyStyle方法的具体用法?C# DataGridViewCellStyle.ApplyStyle怎么用?C# DataGridViewCellStyle.ApplyStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.DataGridViewCellStyle
的用法示例。
在下文中一共展示了DataGridViewCellStyle.ApplyStyle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetInheritedStyle
public override DataGridViewCellStyle GetInheritedStyle (DataGridViewCellStyle inheritedCellStyle, int rowIndex, bool includeColors)
{
DataGridViewCellStyle result = new DataGridViewCellStyle (DataGridView.DefaultCellStyle);
result.ApplyStyle (DataGridView.ColumnHeadersDefaultCellStyle);
if (HasStyle)
result.ApplyStyle (Style);
return result;
}
示例2: GetInheritedStyle
public virtual DataGridViewCellStyle GetInheritedStyle (DataGridViewCellStyle inheritedCellStyle, int rowIndex, bool includeColors) {
/*
* System.InvalidOperationException :: The cell has no associated System.Windows.Forms.DataGridView, or the cell's System.Windows.Forms.DataGridViewCell.ColumnIndex is less than 0.
* System.ArgumentOutOfRangeException :: rowIndex is less than 0, or greater than or equal to the number of rows in the parent System.Windows.Forms.DataGridView.
* */
if (DataGridView == null)
throw new InvalidOperationException ("Cell is not in a DataGridView. The cell cannot retrieve the inherited cell style.");
if (rowIndex < 0 || rowIndex >= DataGridView.Rows.Count)
throw new ArgumentOutOfRangeException ("rowIndex");
// Start with DataGridView.DefaultCellStyle
DataGridViewCellStyle result = new DataGridViewCellStyle (DataGridView.DefaultCellStyle);
// If we have a column, add OwningColumn.DefaultCellStyle
if (OwningColumn != null)
result.ApplyStyle (OwningColumn.DefaultCellStyle);
// Add DataGridView.RowsDefaultCellStyle
result.ApplyStyle (DataGridView.RowsDefaultCellStyle);
// If we are an odd row, add DataGridView.AlternatingRowsDefaultCellStyle
if (rowIndex % 2 == 1)
result.ApplyStyle (DataGridView.AlternatingRowsDefaultCellStyle);
// Add Row.DefaultCellStyle
result.ApplyStyle (DataGridView.Rows.SharedRow (rowIndex).DefaultCellStyle);
// Add cell's style
if (HasStyle)
result.ApplyStyle (Style);
return result;
}