AODL.Document.Content.Tables.Row.InsertCellAt C# (CSharp) Method

InsertCellAt() public method

Inserts the cell at the given zero based position.
public InsertCellAt ( int position, Cell cell ) : void
position int The position.
cell Cell The cell.
return void
		public void InsertCellAt(int position, Cell cell)
		{
			// Phil Jollans 16-Feb-2008: Largely rewritten
			if ( _cells.Count > position )
			{
				// We need to ask Lars how he intended this list to work.
				// Note that Table.Row_OnRowChanged() adds cells to all rows when
				// we add a cell to a single row.
				_cells.RemoveAt ( position ) ;
				_cells.Insert ( position, cell ) ;
			}
			else
			{
				while ( _cells.Count < position  )
				{
					_cells.Add ( new Cell ( this.Table.Document ) ) ;
				}
				
				_cells.Add(cell);
			}
		}

Usage Example

Exemplo n.º 1
0
        /// <summary>
        /// Inserts the cell at the specified position. Both indexes are 1-based indexes!
        /// The RowCollection, the rows CellCollection and the ColumnCollection
        /// will be resized automatically.
        /// </summary>
        /// <param name="rowIndex">Index of the row.</param>
        /// <param name="columnIndex">Index of the column.</param>
        /// <param name="cell">The cell.</param>
        public void InsertCellAt(int rowIndex, int columnIndex, Cell cell)
        {
            if (this.RowCollection.Count <= rowIndex)
            {
                for (int i = 0; i < rowIndex - this.RowCollection.Count; i++)
                {
                    this.RowCollection.Add(new Row(this, "row" + this.RowCollection.Count.ToString() + i.ToString()));
                }

                this.RowCollection[rowIndex - 1].InsertCellAt(columnIndex - 1, cell);
                cell.Row = this.RowCollection[rowIndex - 1];
            }
            else if (this.RowCollection.Count + 1 == rowIndex)
            {
                Row row = new Row(this, this.RowCollection[this.RowCollection.Count - 1].StyleName);
                row.InsertCellAt(columnIndex - 1, cell);
                cell.Row = row;
                this.RowCollection.Add(row);
            }
            else
            {
                this.RowCollection[rowIndex - 1].InsertCellAt(columnIndex - 1, cell);
                cell.Row = this.RowCollection[rowIndex - 1];
            }
        }
All Usage Examples Of AODL.Document.Content.Tables.Row::InsertCellAt