// 插入本Line到某行。调用前,table.RowCount已经增量 // parameters: // nRow 从0开始计数 internal void InsertToTable(TableLayoutPanel table, int nRow) { this.Container.DisableUpdate(); try { Debug.Assert(table.RowCount == this.Container.Items.Count + 3, ""); // 先移动后方的 for (int i = (table.RowCount - 1) - 3; i >= nRow; i--) { TemplateLine line = this.Container.Items[i]; // color Label label = line.label_color; table.Controls.Remove(label); table.Controls.Add(label, 0, i + 1 + 1); // fieldname Label fieldName = line.label_fieldName; table.Controls.Remove(fieldName); table.Controls.Add(fieldName, 0, i + 1 + 1); // subfieldname Label subfieldName = line.label_subfieldName; table.Controls.Remove(subfieldName); table.Controls.Add(subfieldName, 0, i + 1 + 1); // subfield content TextBox subfieldContent = line.textBox_subfieldContent; table.Controls.Remove(subfieldContent); table.Controls.Add(subfieldContent, 1, i + 1 + 1); } table.Controls.Add(this.label_color, 0, nRow + 1); table.Controls.Add(this.textBox_subfieldContent, 1, nRow + 1); } finally { this.Container.EnableUpdate(); } // events AddEvents(); }
public TemplateLine InsertNewItem(int index) { this.DisableUpdate(); // 防止闪动 try { this.tableLayoutPanel_content.RowCount += 1; this.tableLayoutPanel_content.RowStyles.Insert(index + 1, new System.Windows.Forms.RowStyle()); TemplateLine item = new TemplateLine(this); item.InsertToTable(this.tableLayoutPanel_content, index); this.Items.Insert(index, item); item.State = ItemState.New; return item; } finally { this.EnableUpdate(); } }
public TemplateLine InsertNewItem(int index) { this.DisableUpdate(); // 防止闪动 try { this.tableLayoutPanel_content.RowCount += 1; this.tableLayoutPanel_content.RowStyles.Insert(index + 1, new System.Windows.Forms.RowStyle()); TemplateLine item = new TemplateLine(this); item.InsertToTable(this.tableLayoutPanel_content, index); this.Items.Insert(index, item); item.State = ItemState.New; return(item); } finally { this.EnableUpdate(); } }