void RefreshControls() { var controls = tableLayoutPanel1.Controls.Cast <TicketToken>().ToArray(); tableLayoutPanel1.Controls.Clear(); using (var q = new QueeuingEntities()) { foreach (var i in q.Transactions) { var token = new TicketToken(); token.Dock = DockStyle.Fill; token.Transaction = i.Name.ToUpper(); foreach (var j in i.Counters) { token.Counters += "COUNTER " + j.CounterNumber + " "; } token.OnSelected += (X, Y) => { ShowConfirmation(i.Id); }; tableLayoutPanel1.Controls.Add(token); } } foreach (var i in controls) { i.Dispose(); } }
private void Main_Load(object sender, EventArgs e) { using (var q = new QueeuingEntities()) { foreach (var i in q.Transactions) { var token = new TicketToken(); token.Dock = DockStyle.Fill; token.Transaction = i.Name.ToUpper(); foreach (var j in i.Counters) { token.Counters += "COUNTER " + j.CounterNumber + " "; } token.OnSelected += (X, Y) => { ShowConfirmation(i.Id); }; //flowLayoutPanel1.Controls.Add(token); tableLayoutPanel1.Controls.Add(token); } } }