using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace QualityAndOrder { partial class QualityOrderForm { private void AddKeyPadForTab2() { for (var i = 1; i < 10; i++) { var btn = new Button() { Name = "_2" + i, Text = i.ToString(), Size = new Size(80, 60), TextAlign = ContentAlignment.MiddleCenter, Margin = new Padding { All = 10 }, Font = new Font("宋体", 15) }; btn.Click += (sender, e) => { //numberBox.Text += btn.Text; }; tab2KeyPanel.Controls.Add(btn); } var zero = new Button() { Name = "_20", Text = "0", Size = new Size(80, 60), TextAlign = ContentAlignment.MiddleCenter, Margin = new Padding { All = 10 }, Font = new Font("宋体", 15) }; zero.Click += (sender, e) => { //if (!string.IsNullOrEmpty(numberBox.Text)) // numberBox.Text += "0"; }; tab2KeyPanel.Controls.Add(zero); var back = new Button() { Name = "_2back", Text = "←", Size = new Size(80, 60), TextAlign = ContentAlignment.MiddleCenter, Margin = new Padding { All = 10 }, Font = new Font("宋体", 15) }; back.Click += (sender, e) => { //if (!string.IsNullOrEmpty(numberBox.Text)) // numberBox.Text = numberBox.Text.Substring(0, numberBox.Text.Length - 1); }; tab2KeyPanel.Controls.Add(back); var clear = new Button() { Name = "_2clear", Text = "清空", Size = new Size(80, 60), TextAlign = ContentAlignment.MiddleCenter, Margin = new Padding { All = 10 }, Font = new Font("宋体", 15) }; clear.Click += (sender, e) => { //numberBox.Text = null; }; tab2KeyPanel.Controls.Add(clear); } } }