• 动态增删改控件


    private void AddGroup()
            {
                for (int i = 0; i < 5; i++)
                {
                    GroupBox gbox = new GroupBox();
                    gbox.Name = "gbox" + i;
                    gbox.Text = i + "号清洗机";
                    gbox.Size = new Size(1280, 200);
                    gbox.Location = new Point(30, 230 * i + 30);
                    this.Controls.Add(gbox);
                    AddStepLab(gbox);
                }
            }
    
            private void AddStepLab(GroupBox gbox)
            {
                int jiange = (1280 - 100 * 5) / 6;
                for (int i = 0; i < 5; i++)
                {
                    Label lab = new Label();
                    lab.Name = "labStep" + i;
                    lab.Text = i + "次洗";
                    lab.TextAlign = ContentAlignment.MiddleCenter;//文字居中
                    lab.Location = new Point((jiange + 100) * i + jiange, 80);
                    lab.Size = new Size(100, 40);
                    lab.BorderStyle = BorderStyle.FixedSingle;
                    gbox.Controls.Add(lab);
                }
            }
    
            private void AddLabInfo(int gboxNum, int labStepNum)
            {
                Control gbox = this.Controls.Find("gbox" + gboxNum, false)[0];
                Control labS = gbox.Controls.Find("labStep" + labStepNum, false)[0];
                for (int i = 0; i < 2; i++)
                {
                    Label lab = new Label();
                    lab.Name = "NJ100" + i;
                    lab.Text = "EMM100/NJ100";
                    if (i == 0)
                        lab.Location = new Point(labS.Location.X, labS.Location.Y - 20);
                    else
                        lab.Location = new Point(labS.Location.X, labS.Location.Y + labS.Size.Height + 20);
    
                    lab.Size = new Size(100, 30);
                    gbox.Controls.Add(lab);
                }
            }
            private void DelLabInfo(string gboxNum, string EndCode)
            {
                Control gbox = this.Controls.Find("gbox" + gboxNum, false)[0];
                for (int i = 0; i < 2; i++)
                {
                    Control labS = gbox.Controls.Find(EndCode + i, false)[0];
                    gbox.Controls.Remove(labS);
                }
            }
  • 相关阅读:
    JavaScript-循环
    JavaScript-条件判断
    JavaScript-对象
    Vue快速入门
    Typora中的MarkDown语法
    (已解决)ERROR: In file './docker-compose.yml', service 'networks' must be a mapping not an array
    mac常用快捷键
    Python数据分析
    Python列表和元组
    Selenium工具爬取商品
  • 原文地址:https://www.cnblogs.com/qixinjian/p/11881728.html
Copyright © 2020-2023  润新知