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; }
public override DataGridViewCellStyle GetInheritedStyle(DataGridViewCellStyle inheritedCellStyle, int rowIndex, bool includeColors) { DataGridViewCellStyle result = new DataGridViewCellStyle(DataGridView.DefaultCellStyle); result.ApplyStyle(DataGridView.RowHeadersDefaultCellStyle); if (HasStyle) { result.ApplyStyle(Style); } return(result); }
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; }