Ejemplo n.º 1
0
            /// <summary>
            /// Sets the element in the specified column index.
            /// </summary>
            public void SetCell(int index, Element cell)
            {
                while (Table._columnCount <= index)
                {
                    foreach (var row in Table._rows)
                    {
                        row.Cells.Add(null);
                    }
                    if (Table._header != null)
                    {
                        Table._header.Cells.Add(null);
                    }
                    ++Table._columnCount;
                }
                var current = Cells[index];

                if (cell == null)
                {
                    if (current != null)
                    {
                        current.Remove();
                        Cells[index] = null;
                    }
                    return;
                }
                if (cell.Tag != Tag.TableCell)
                {
                    var tableCell = new Element(Tag.TableCell);
                    cell.Parent = tableCell;
                    cell        = tableCell;
                }
                if (current == null)
                {
                    Cells[index] = cell;
                    cell.Parent  = RowElement;
                }
                else
                {
                    current.Replace(cell);
                    Cells.Replace(current, cell);
                }
            }