一个窗体上有5个文本框,33个按钮的text 分别是1 到33,
现在要点击按钮,在文本框中显示text,每个文本框接收6个按钮的text后,焦点就自动转入下个文本框或用鼠标点也行,(暂不接受键盘输入),怎么实现?
另33个按钮做成数组怎么做?

解决方案 »

  1.   

    //参考如下代码
        public partial class Form1 : Form
        {
            public TextBox[] TextBoxs = new TextBox[5];
            public Button[] Buttons = new Button[33];
            public int TextBoxIndex = 0;
            public int AppendCount = 0;
            public Form1()
            {
                InitializeComponent();
                for (int i = 0; i < TextBoxs.Length; i++)
                {
                    TextBoxs[i] = new TextBox();
                    TextBoxs[i].Left = i * 100;
                    TextBoxs[i].Parent = this;
                }
                for (int i = 0; i < Buttons.Length; i++)
                {
                    Buttons[i] = new Button();
                    Buttons[i].Top = (i % 10) * 22 + 30;
                    Buttons[i].Left = (i / 10) * 80;
                    Buttons[i].Text = i.ToString();
                    Buttons[i].Parent = this;
                    Buttons[i].Click += button1_Click;
                }
            }        private void button1_Click(object sender, EventArgs e)
            {
                if (AppendCount >= 5)
                {
                    TextBoxIndex = (TextBoxIndex + 1) % TextBoxs.Length;
                    AppendCount = 0;
                }
                AppendCount++;
                TextBoxs[TextBoxIndex].SelectedText = ((Button)sender).Text;
            }
       }