private void UpdateEntireTpl() { int i = 0; _eventsOn = false; softBillSplitTpl.RowStyles.Clear(); softBillSplitTpl.Controls.Clear(); //anytime we get here it means the table has changed //or it's the first time var softBillNames = _year.GetSoftBillKeys(_monthSelected); _split = new Dictionary <string, decimal>(); foreach (var sb in softBillNames) { _split.Add(sb, 0); } foreach (var kvp in _split) { softBillSplitTpl.RowStyles.Add(new RowStyle(SizeType.Absolute, 28)); Label lblTitle = new Label(); lblTitle.Text = string.Format("{0}:", kvp.Key); lblTitle.TabIndex = (i * 2); lblTitle.Margin = new Padding(0); lblTitle.Dock = DockStyle.Fill; softBillSplitTpl.Controls.Add(lblTitle, 0, i); TextBox txtValue = new TextBox(); txtValue.TabIndex = (i * 2) + 1; txtValue.Margin = new Padding(0); txtValue.Dock = DockStyle.Fill; //txtValue.TextChanged += new EventHandler(SoftGroupSplit_TextChanged); txtValue.Name = kvp.Key + "_tb"; txtValue.Text = kvp.Value.ToString(); softBillSplitTpl.Controls.Add(txtValue, 1, i); Button remainder = new Button(); remainder.Text = "Use Remainder"; remainder.TabIndex = (i * 2) + 2; remainder.Margin = new Padding(0); remainder.Dock = DockStyle.Fill; remainder.Click += new EventHandler(remainder_Click); remainder.Name = kvp.Key + "_btn"; remainder.AutoSize = true; softBillSplitTpl.Controls.Add(remainder, 2, i); i++; } _eventsOn = true; }