protected override DataGridViewCellCollection CreateCellsInstance() { DataGridViewCellCollection viewCellCollection = new DataGridViewCellCollection((DataGridViewRow)this); for (int index = 0; index < this.cellCount; ++index) viewCellCollection.Add((DataGridViewCell)new DataGridViewTextBoxCell()); return viewCellCollection; }
public static void AddText(this DataGridViewCellCollection c, string text) { c.Add( new DataGridViewTextBoxCell { Value = text } ); }
public void CreateCells(DataGridView dataGridView) { if (dataGridView == null) { throw new ArgumentNullException("DataGridView is null."); } if (dataGridView.Rows.Contains(this)) { throw new InvalidOperationException("The row already exists in the DataGridView."); } DataGridViewCellCollection newCellCollection = new DataGridViewCellCollection(this); foreach (DataGridViewColumn column in dataGridView.Columns) { if (column.CellTemplate == null) { throw new InvalidOperationException("Cell template not set in column: " + column.Index.ToString() + "."); } newCellCollection.Add((DataGridViewCell)column.CellTemplate.Clone()); } cells = newCellCollection; }
public void CreateCells (DataGridView dataGridView) { if (dataGridView == null) { throw new ArgumentNullException("DataGridView is null."); } if (dataGridView.Rows.Contains(this)) { throw new InvalidOperationException("The row already exists in the DataGridView."); } DataGridViewCellCollection newCellCollection = new DataGridViewCellCollection(this); foreach (DataGridViewColumn column in dataGridView.Columns) { if (column.CellTemplate == null) { throw new InvalidOperationException("Cell template not set in column: " + column.Index.ToString() + "."); } newCellCollection.Add((DataGridViewCell) column.CellTemplate.Clone()); } cells = newCellCollection; }