public void AddPanel(View_FormulaInfoModel model) { Panel currentPanel = new Panel(); currentPanel.Dock = DockStyle.Top; currentPanel.Height = (int)this.Font.GetHeight() + 20; currentPanel.BackColor = Color.Transparent; currentPanel.BorderStyle = LabelBorderStyle; currentPanel.Tag = model.BarCode; this.Controls.Add(currentPanel); currentPanel.BringToFront(); if (!dcPanel.ContainsKey(model.BarCode)) { dcPanel.Add(model.BarCode, currentPanel); } for (int i = 0; i < 6; i++) { Label lbl = new Label(); lbl.Width = this.Width / 7 + 1; lbl.AutoSize = false; lbl.ForeColor = this.ForeColor; switch (i) { case 0: lbl.Text = model.BarCode; break; case 1: lbl.Text = model.DeviceName; break; case 2: lbl.Text = model.Customer; break; case 3: lbl.Text = model.ProductSpecification; break; case 4: lbl.Text = model.CylinderNum.ToString(); break; case 5: lbl.Text = model.CompleteCylinderNum.ToString(); break; } lbl.TextAlign = ContentAlignment.MiddleCenter; lbl.Dock = DockStyle.Left; lbl.Font = this.Font; lbl.BorderStyle = LabelBorderStyle; currentPanel.Controls.Add(lbl); lbl.BringToFront(); } ButtonEx btn = new ButtonEx(); btn.Text = "删除"; btn.Font = this.Font; btn.Click += btn_Click; btn.Dock = DockStyle.Left; btn.Width = this.Width / 7 + 1; btn.Tag = model.BarCode; currentPanel.Controls.Add(btn); btn.BringToFront(); }
private void AddBtn() { for (int i = 0; i < 10; i++) { ButtonEx btn = new ButtonEx(); btn.Text = i.ToString(); btn.Font = this.Font; btn.Radius = 15; btn.Width = 10; btn.Dock = DockStyle.Left; btn.Click += btn_Click; this.Controls.Add(btn); btn.BringToFront(); } ButtonEx btnDot = new ButtonEx(); btnDot.Text = "."; btnDot.Font = this.Font; btnDot.Radius = 15; btnDot.Width = 10; btnDot.Dock = DockStyle.Left; btnDot.Click += btn_Click; this.Controls.Add(btnDot); btnDot.BringToFront(); ButtonEx btnDel = new ButtonEx(); btnDel.Text = "清零"; btnDel.Font = this.Font; btnDel.Radius = 15; btnDel.Width = 10; btnDel.Dock = DockStyle.Left; btnDel.Click += btn_Click; this.Controls.Add(btnDel); btnDel.BringToFront(); }