public override object Clone() { DataGridViewSmallIconCell cell = (DataGridViewSmallIconCell)base.Clone(); cell.IconShown = this.IconShown; cell.IconColor = this.IconColor; cell.IconType = this.IconType; cell.IconPadding = this.IconPadding; return(cell); }
private DataGridViewCell createAndInitCell(CustomDataGridViewColumnDescriptor <T> columnDescriptor) { DataGridViewCell cell = getCellByType(columnDescriptor.Type); if (columnDescriptor.Type == DataGridViewColumnType.CheckBox) { DataGridViewCheckBoxCell typedCell = (DataGridViewCheckBoxCell)cell; typedCell.FalseValue = false; typedCell.TrueValue = true; } if (columnDescriptor.Type == DataGridViewColumnType.Image) { DataGridViewImageCell typedCell = (DataGridViewImageCell)cell; typedCell.ImageLayout = DataGridViewImageCellLayout.Zoom; typedCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; } if (columnDescriptor.Type == DataGridViewColumnType.ImageButton) { DataGridViewImageButtonCell typedCell = (DataGridViewImageButtonCell)cell; typedCell.Image = columnDescriptor.ButtonImage; typedCell.ImagePadding = columnDescriptor.ButtonImagePadding; } if (columnDescriptor.Type == DataGridViewColumnType.SmallIcon) { DataGridViewSmallIconCell typedCell = (DataGridViewSmallIconCell)cell; typedCell.IconShown = columnDescriptor.IconShown; typedCell.IconColor = columnDescriptor.IconColor; typedCell.IconType = columnDescriptor.IconType; typedCell.IconPadding = columnDescriptor.IconPadding; } if (columnDescriptor.Type == DataGridViewColumnType.Button) { cell.Value = columnDescriptor.ButtonText; } if (columnDescriptor.Type == DataGridViewColumnType.DisableButton) { cell.Value = columnDescriptor.ButtonText; } if (columnDescriptor.Type == DataGridViewColumnType.ComboBox) { DataGridViewComboBoxCell typedCell = (DataGridViewComboBoxCell)cell; typedCell.DisplayStyle = DataGridViewComboBoxDisplayStyle.DropDownButton; typedCell.ValueMember = "Value"; typedCell.DisplayMember = "Label"; typedCell.Items.AddRange(columnDescriptor.DropDownPopulatorMethod?.Invoke(item, cell)); } Cells.Add(cell); if (columnDescriptor.Type == DataGridViewColumnType.TextBox) { cell.ReadOnly = !columnDescriptor.TextEditable; } if (columnDescriptor.Type == DataGridViewColumnType.SmallIcon) { cell.ReadOnly = true; } columnDescriptor.InitializerMethod?.Invoke(item, cell); columnDescriptor.UpdaterMethod?.Invoke(item, cell); return(cell); }