public void AddLine(TopTableHeader line, params TopTableCell[] cells) { if (cells == null) { return; } if (Columns.Count == 0) { throw new Exception("You can't add lines because there is no columns defined."); } if (cells.Length > Columns.Count) { throw new Exception("Too much columns!!"); } line.Table = this; line.RatioWidth = Lines.Count == 0 ? line.RatioWidth : Lines.First().RatioWidth; for (var i = 0; i < cells.Length; i++) { cells[i].Table = this; cells[i].Column = Columns[i]; cells[i].Line = line; line.Cells.Add(cells[i]); Columns[i].Cells.Add(cells[i]); } Lines.Add(line); }
public void AddLine(TopTableHeader line, params TopTableCell[] cells) { if (cells == null) { return; } if (Columns.Count == 0) { throw new Exception("You can't add lines because there is no columns defined. Call DefineColumns() once before calling AddLine()."); } if (cells.Length < Columns.Count) { throw new Exception(string.Format("Not enough columns!! Trying to insert {0} columns with {1} column headers defined.", cells.Length, Columns.Count)); } if (cells.Length > Columns.Count) { throw new Exception(string.Format("Too much columns!! Trying to insert {0} columns with only {1} column headers defined.", cells.Length, Columns.Count)); } line.Table = this; line.Siblings = Lines; line.RatioWidth = Lines.Count == 0 ? line.RatioWidth : Lines.First().RatioWidth; for (var i = 0; i < cells.Length; i++) { cells[i].Table = this; cells[i].Column = Columns[i]; cells[i].Line = line; line.Cells.Add(cells[i]); Columns[i].Cells.Add(cells[i]); } line.Position = Lines.Count; Lines.Add(line); }