C#_代码生成控件,并放置再其他控件上

   for (int i = 0; i < EhphmName.Length; i++)//动态创造控件
            {
                TabPage page = new TabPage();
                page.Text = EhphmName[i];
                switch (i)
                {
                    case 0:
                       
                        break;
                    case 1:
                        int pos_x = 10, pos_y = 50;
                        for (int j = 0; j < EhphmGPSThings.Length; j++)
                        {
                            if (j % 10 == 0 && j != 0)
                            {
                                pos_x += 360;
                                pos_y -= 400;
                            }
                            Label tempLabel = new Label();
                            tempLabel.Text = EhphmGPSThings[j] + ":";
                            tempLabel.Size = new Size(80, 30);
                            tempLabel.Font = font;
                            tempLabel.Location = new Point(pos_x, pos_y + j * 40);
                            page.Controls.Add(tempLabel);
                            TextBox tempTextBox = new TextBox();
                            tempTextBox.Name = EhphmGPSThings[j];
                            tempTextBox.Size = new Size(200, 10);
                            tempTextBox.Font = font;
                            tempTextBox.Location = new Point(pos_x + 120, pos_y + j * 40);
                            page.Controls.Add(tempTextBox);
                            GPSEControls.Add(tempTextBox);
                        }
                        break;
                    case 2:
                        pos_x = 10;
                        pos_y = 50;
                        for (int j = 0; j < EhphmBD2Things.Length; j++)
                        {
                            if (j % 10 == 0 && j != 0)
                            {
                                pos_x += 360;
                                pos_y -= 400;
                            }
                            Label tempLabel = new Label();
                            tempLabel.Text = EhphmBD2Things[j] + ":";
                            tempLabel.Size = new Size(80, 30);
                            tempLabel.Font = font;
                            tempLabel.Location = new Point(pos_x, pos_y + j * 40);
                            page.Controls.Add(tempLabel);
                            TextBox tempTextBox = new TextBox();
                            tempTextBox.Name = EhphmBD2Things[j];
                            tempTextBox.Size = new Size(200, 10);
                            tempTextBox.Font = font;
                            tempTextBox.Location = new Point(pos_x + 120, pos_y + j * 40);
                            page.Controls.Add(tempTextBox);
                            BD2EControls.Add(tempTextBox);
                        }
                        break;
                    case 3:
                        pos_x = 10;
                        pos_y = 50;
                        for (int j = 0; j < EhphmGLOThings.Length; j++)
                        {
                            if (j % 10 == 0 && j != 0)
                            {
                                pos_x += 450;
                                pos_y -= 400;
                            }
                            Label tempLabel = new Label();
                            tempLabel.Text = EhphmGLOThings[j] + ":";
                            tempLabel.Size = new Size(100, 30);
                            tempLabel.Font = font;
                            tempLabel.Location = new Point(pos_x, pos_y + j * 40);
                            page.Controls.Add(tempLabel);
                            TextBox tempTextBox = new TextBox();
                            tempTextBox.Name = EhphmGLOThings[j];
                            tempTextBox.Size = new Size(250, 10);
                            tempTextBox.Font = font;
                            tempTextBox.Location = new Point(pos_x + 120, pos_y + j * 40);
                            page.Controls.Add(tempTextBox);
                            GLOEControls.Add(tempTextBox);
                        }
                        break;
                    case 4:
                        pos_x = 10;
                        pos_y = 50;
                        for (int j = 0; j < IonutcGPSThings.Length; j++)
                        {
                            if (j % 10 == 0 && j != 0)
                            {
                                pos_x += 450;
                                pos_y -= 400;
                            }
                            Label tempLabel = new Label();
                            tempLabel.Text = IonutcGPSThings[j] + ":";
                            tempLabel.Size = new Size(160, 30);
                            tempLabel.Font = font;
                            tempLabel.Location = new Point(pos_x, pos_y + j * 40);
                            page.Controls.Add(tempLabel);
                            TextBox tempTextBox = new TextBox();
                            tempTextBox.Name = IonutcGPSThings[j];
                            tempTextBox.Size = new Size(250, 10);
                            tempTextBox.Font = font;
                            tempTextBox.Location = new Point(pos_x + 160, pos_y + j * 40);
                            page.Controls.Add(tempTextBox);
                            GPSIControls.Add(tempTextBox);
                        }
                        break;
                    case 5:
                        pos_x = 10;
                        pos_y = 50;
                        for (int j = 0; j < IonutcBD2Things.Length; j++)
                        {
                            if (j % 10 == 0 && j != 0)
                            {
                                pos_x += 450;
                                pos_y -= 400;
                            }
                            Label tempLabel = new Label();
                            tempLabel.Text = IonutcBD2Things[j] + ":";
                            tempLabel.Size = new Size(160, 30);
                            tempLabel.Font = font;
                            tempLabel.Location = new Point(pos_x, pos_y + j * 40);
                            page.Controls.Add(tempLabel);
                            TextBox tempTextBox = new TextBox();
                            tempTextBox.Name = IonutcBD2Things[j];
                            tempTextBox.Size = new Size(250, 10);
                            tempTextBox.Font = font;
                            tempTextBox.Location = new Point(pos_x + 160, pos_y + j * 40);
                            page.Controls.Add(tempTextBox);
                            BD2IControls.Add(tempTextBox);
                        }
                        break;
                    case 6:
                        pos_x = 10;
                        pos_y = 50;
                        for (int j = 0; j < GGAThings.Length; j++)
                        {
                            if (j % 10 == 0 && j != 0)
                            {
                                pos_x += 400;
                                pos_y -= 400;
                            }
                            Label tempLabel = new Label();
                            tempLabel.Text = GGAThings[j] + ":";
                            tempLabel.Size = new Size(160, 30);
                            tempLabel.Font = font;
                            tempLabel.Location = new Point(pos_x, pos_y + j * 40);
                            page.Controls.Add(tempLabel);
                            TextBox tempTextBox = new TextBox();
                            tempTextBox.Name = GGAThings[j];
                            tempTextBox.Size = new Size(200, 10);
                            tempTextBox.Font = font;
                            tempTextBox.Location = new Point(pos_x + 180, pos_y + j * 40);
                            page.Controls.Add(tempTextBox);
                            GGAControls.Add(tempTextBox);
                        }
                        break;
                    case 7:
                        pos_x = 10;
                        pos_y = 50;
                        for (int j = 0; j < GSAThings.Length; j++)
                        {
                            if (j % 10 == 0 && j != 0)
                            {
                                pos_x += 400;
                                pos_y -= 400;
                            }
                            Label tempLabel = new Label();
                            tempLabel.Text = GSAThings[j] + ":";
                            tempLabel.Size = new Size(160, 30);
                            tempLabel.Font = font;
                            tempLabel.Location = new Point(pos_x, pos_y + j * 40);
                            page.Controls.Add(tempLabel);
                            TextBox tempTextBox = new TextBox();
                            tempTextBox.Name = GSAThings[j];
                            tempTextBox.Size = new Size(200, 10);
                            tempTextBox.Font = font;
                            tempTextBox.Location = new Point(pos_x + 180, pos_y + j * 40);
                            page.Controls.Add(tempTextBox);
                            GSAControls.Add(tempTextBox);
                        }
                        break;
                    case 8:
                        pos_x = 10;
                        pos_y = 50;
                        for (int j = 0; j < GSTThings.Length; j++)
                        {
                            if (j % 10 == 0 && j != 0)
                            {
                                pos_x += 400;
                                pos_y -= 400;
                            }
                            Label tempLabel = new Label();
                            tempLabel.Text = GSTThings[j] + ":";
                            tempLabel.Size = new Size(160, 30);
                            tempLabel.Font = font;
                            tempLabel.Location = new Point(pos_x, pos_y + j * 40);
                            page.Controls.Add(tempLabel);
                            TextBox tempTextBox = new TextBox();
                            tempTextBox.Name = GSTThings[j];
                            tempTextBox.Size = new Size(200, 10);
                            tempTextBox.Font = font;
                            tempTextBox.Location = new Point(pos_x + 180, pos_y + j * 40);
                            page.Controls.Add(tempTextBox);
                            GSTControls.Add(tempTextBox);
                        }
                        break;
                    case 9:
                        if (true)
                        {
                            TextBox tempTextBox = new TextBox();
                            tempTextBox.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom;
                            tempTextBox.Multiline = true;
                            tempTextBox.Size = 数据显示.Size;
                            tempTextBox.Location = new Point(0, 0);
                            tempTextBox.Enabled = false;
                            page.Controls.Add(tempTextBox);
                            GSVControls.Add(tempTextBox);
                        }
                        break;
                    case 10:
                        pos_x = 10;
                        pos_y = 50;
                        for (int j = 0; j < HDTThings.Length; j++)
                        {
                            if (j % 10 == 0 && j != 0)
                            {
                                pos_x += 400;
                                pos_y -= 400;
                            }
                            Label tempLabel = new Label();
                            tempLabel.Text = HDTThings[j] + ":";
                            tempLabel.Size = new Size(160, 30);
                            tempLabel.Font = font;
                            tempLabel.Location = new Point(pos_x, pos_y + j * 40);
                            page.Controls.Add(tempLabel);
                            TextBox tempTextBox = new TextBox();
                            tempTextBox.Name = HDTThings[j];
                            tempTextBox.Size = new Size(200, 10);
                            tempTextBox.Font = font;
                            tempTextBox.Location = new Point(pos_x + 180, pos_y + j * 40);
                            page.Controls.Add(tempTextBox);
                            HDTControls.Add(tempTextBox);
                        }
                        break;
                    case 11:
                        pos_x = 10;
                        pos_y = 50;
                        for (int j = 0; j < RMCThings.Length; j++)
                        {
                            if (j % 10 == 0 && j != 0)
                            {
                                pos_x += 400;
                                pos_y -= 400;
                            }
                            Label tempLabel = new Label();
                            tempLabel.Text = RMCThings[j] + ":";
                            tempLabel.Size = new Size(160, 30);
                            tempLabel.Font = font;
                            tempLabel.Location = new Point(pos_x, pos_y + j * 40);
                            page.Controls.Add(tempLabel);
                            TextBox tempTextBox = new TextBox();
                            tempTextBox.Name = RMCThings[j];
                            tempTextBox.Size = new Size(200, 10);
                            tempTextBox.Font = font;
                            tempTextBox.Location = new Point(pos_x + 180, pos_y + j * 40);
                            page.Controls.Add(tempTextBox);
                            RMCControls.Add(tempTextBox);
                        }
                        break;
                    case 12:
                        pos_x = 10;
                        pos_y = 50;
                        for (int j = 0; j < VTGThings.Length; j++)
                        {
                            if (j % 10 == 0 && j != 0)
                            {
                                pos_x += 400;
                                pos_y -= 400;
                            }
                            Label tempLabel = new Label();
                            tempLabel.Text = VTGThings[j] + ":";
                            tempLabel.Size = new Size(160, 30);
                            tempLabel.Font = font;
                            tempLabel.Location = new Point(pos_x, pos_y + j * 40);
                            page.Controls.Add(tempLabel);
                            TextBox tempTextBox = new TextBox();
                            tempTextBox.Name = VTGThings[j];
                            tempTextBox.Size = new Size(200, 10);
                            tempTextBox.Font = font;
                            tempTextBox.Location = new Point(pos_x + 180, pos_y + j * 40);
                            page.Controls.Add(tempTextBox);
                            VTGControls.Add(tempTextBox);
                        }
                        break;
                    case 13:
                        pos_x = 10;
                        pos_y = 50;
                        for (int j = 0; j < ZDAThings.Length; j++)
                        {
                            if (j % 10 == 0 && j != 0)
                            {
                                pos_x += 400;
                                pos_y -= 400;
                            }
                            Label tempLabel = new Label();
                            tempLabel.Text = ZDAThings[j] + ":";
                            tempLabel.Size = new Size(160, 30);
                            tempLabel.Font = font;
                            tempLabel.Location = new Point(pos_x, pos_y + j * 40);
                            page.Controls.Add(tempLabel);
                            TextBox tempTextBox = new TextBox();
                            tempTextBox.Name = ZDAThings[j];
                            tempTextBox.Size = new Size(200, 10);
                            tempTextBox.Font = font;
                            tempTextBox.Location = new Point(pos_x + 180, pos_y + j * 40);
                            page.Controls.Add(tempTextBox);
                            ZDAControls.Add(tempTextBox);
                        }
                        break;
                    case 14:
                        pos_x = 10;
                        pos_y = 50;
                        for (int j = 0; j < BestPosA.Length; j++)
                        {
                            if (j % 11 == 0 && j != 0)
                            {
                                pos_x += 400;
                                pos_y -= 400;
                            }
                            Label tempLabel = new Label();
                            tempLabel.Text = BestPosA[j] + ":";
                            tempLabel.Size = new Size(160, 30);
                            tempLabel.Font = font;
                            tempLabel.Location = new Point(pos_x, pos_y + j * 40);
                            page.Controls.Add(tempLabel);
                            TextBox tempTextBox = new TextBox();
                            tempTextBox.Name = BestPosA[j];
                            tempTextBox.Size = new Size(200, 10);
                            tempTextBox.Font = font;
                            tempTextBox.Location = new Point(pos_x + 180, pos_y + j * 40);
                            page.Controls.Add(tempTextBox);
                            BestPosAControls.Add(tempTextBox);
                        }
                        break;
                    case 15:
                        pos_x = 10;
                        pos_y = 50;
                        for (int j = 0; j < BestVelA.Length; j++)
                        {
                            if (j % 11 == 0 && j != 0)
                            {
                                pos_x += 400;
                                pos_y -= 400;
                            }
                            Label tempLabel = new Label();
                            tempLabel.Text = BestVelA[j] + ":";
                            tempLabel.Size = new Size(160, 30);
                            tempLabel.Font = font;
                            tempLabel.Location = new Point(pos_x, pos_y + j * 40);
                            page.Controls.Add(tempLabel);
                            TextBox tempTextBox = new TextBox();
                            tempTextBox.Name = BestVelA[j];
                            tempTextBox.Size = new Size(200, 10);
                            tempTextBox.Font = font;
                            tempTextBox.Location = new Point(pos_x + 180, pos_y + j * 40);
                            page.Controls.Add(tempTextBox);
                            BestVelAControls.Add(tempTextBox);
                        }
                        break;
                    case 16:
                        pos_x = 10;
                        pos_y = 50;
                        for (int j = 0; j < HeadingMessage.Length; j++)
                        {
                            if (j % 11 == 0 && j != 0)
                            {
                                pos_x += 400;
                                pos_y -= 400;
                            }
                            Label tempLabel = new Label();
                            tempLabel.Text = HeadingMessage[j] + ":";
                            tempLabel.Size = new Size(160, 30);
                            tempLabel.Font = font;
                            tempLabel.Location = new Point(pos_x, pos_y + j * 40);
                            page.Controls.Add(tempLabel);
                            TextBox tempTextBox = new TextBox();
                            tempTextBox.Name = HeadingMessage[j];
                            tempTextBox.Size = new Size(200, 10);
                            tempTextBox.Font = font;
                            tempTextBox.Location = new Point(pos_x + 180, pos_y + j * 40);
                            page.Controls.Add(tempTextBox);
                            HeadingMessageControls.Add(tempTextBox);
                        }
                        break;
                    case 17:
                        pos_x = 10;
                        pos_y = 50;
                        for (int j = 0; j < PsrDopA.Length; j++)
                        {
                            if (j % 10 == 0 && j != 0)
                            {
                                pos_x += 400;
                                pos_y -= 400;
                            }
                            Label tempLabel = new Label();
                            tempLabel.Text = PsrDopA[j] + ":";
                            tempLabel.Size = new Size(160, 30);
                            tempLabel.Font = font;
                            tempLabel.Location = new Point(pos_x, pos_y + j * 40);
                            page.Controls.Add(tempLabel);
                            TextBox tempTextBox = new TextBox();
                            tempTextBox.Name = PsrDopA[j];
                            tempTextBox.Size = new Size(200, 10);
                            tempTextBox.Font = font;
                            tempTextBox.Location = new Point(pos_x + 180, pos_y + j * 40);
                            page.Controls.Add(tempTextBox);
                            PsrDopaControls.Add(tempTextBox);
                            if (j == PsrDopA.Length - 1)
                            {
                                tempTextBox.Size = new Size(600, 10);
                            }
                        }
                        break;
                    case 18:
                        pos_x = 10;
                        pos_y = 50;
                        for (int j = 0; j < PsrPos.Length; j++)
                        {
                            if (j % 11 == 0 && j != 0)
                            {
                                pos_x += 400;
                                pos_y -= 400;
                            }
                            Label tempLabel = new Label();
                            tempLabel.Text = PsrPos[j] + ":";
                            tempLabel.Size = new Size(160, 30);
                            tempLabel.Font = font;
                            tempLabel.Location = new Point(pos_x, pos_y + j * 40);
                            page.Controls.Add(tempLabel);
                            TextBox tempTextBox = new TextBox();
                            tempTextBox.Name = PsrPos[j];
                            tempTextBox.Size = new Size(200, 10);
                            tempTextBox.Font = font;
                            tempTextBox.Location = new Point(pos_x + 180, pos_y + j * 40);
                            page.Controls.Add(tempTextBox);
                            PsrPosControls.Add(tempTextBox);
                        }
                        break;
                    case 19:
                        pos_x = 10;
                        pos_y = 50;
                        for (int j = 0; j < PsrVel.Length; j++)
                        {
                            if (j % 11 == 0 && j != 0)
                            {
                                pos_x += 400;
                                pos_y -= 400;
                            }
                            Label tempLabel = new Label();
                            tempLabel.Text = PsrVel[j] + ":";
                            tempLabel.Size = new Size(160, 30);
                            tempLabel.Font = font;
                            tempLabel.Location = new Point(pos_x, pos_y + j * 40);
                            page.Controls.Add(tempLabel);
                            TextBox tempTextBox = new TextBox();
                            tempTextBox.Name = PsrVel[j];
                            tempTextBox.Size = new Size(200, 10);
                            tempTextBox.Font = font;
                            tempTextBox.Location = new Point(pos_x + 180, pos_y + j * 40);
                            page.Controls.Add(tempTextBox);
                            PsrVelControls.Add(tempTextBox);
                        }
                        break;
                    case 20:
                        if (true)
                        {
                            TextBox tempTextBox = new TextBox();
                            tempTextBox.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom;
                            tempTextBox.Multiline = true;
                            tempTextBox.Size = 数据显示.Size;
                            tempTextBox.Location = new Point(0, 0);
                            tempTextBox.Enabled = false;
                            page.Controls.Add(tempTextBox);
                            RangeControls.Add(tempTextBox);
                        }
                        break;
                    case 21:
                        if (true)
                        {
                            TextBox tempTextBox = new TextBox();
                            tempTextBox.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom;
                            tempTextBox.Multiline = true;
                            tempTextBox.Size = 数据显示.Size;
                            tempTextBox.Location = new Point(0, 0);
                            tempTextBox.Enabled = false;
                            page.Controls.Add(tempTextBox);
                            SatVisControls.Add(tempTextBox);
                        }
                        break;
                    case 22:
                        pos_x = 10;
                        pos_y = 50;
                        for (int j = 0; j < RefStaTionA.Length; j++)
                        {
                            if (j % 11 == 0 && j != 0)
                            {
                                pos_x += 400;
                                pos_y -= 400;
                            }
                            Label tempLabel = new Label();
                            tempLabel.Text = RefStaTionA[j] + ":";
                            tempLabel.Size = new Size(160, 30);
                            tempLabel.Font = font;
                            tempLabel.Location = new Point(pos_x, pos_y + j * 40);
                            page.Controls.Add(tempLabel);
                            TextBox tempTextBox = new TextBox();
                            tempTextBox.Name = RefStaTionA[j];
                            tempTextBox.Size = new Size(200, 10);
                            tempTextBox.Font = font;
                            tempTextBox.Location = new Point(pos_x + 180, pos_y + j * 40);
                            page.Controls.Add(tempTextBox);
                            RefStaTionAControls.Add(tempTextBox);
                        }
                        break;
                }
                数据显示.TabPages.Add(page);
            }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值