winform在运行时,如下代码实现了在某个位置添加自定义的控件。但是在下次运行winform时,Winform中没有出现上次添加的控件? 求问该怎么实现控件的永远存在?
我写的代码如下:Point pos;
Label newLabel;
PreCeDianControl preCd;
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            if (isAdd == true)
            {
                pos = e.Location;  //获取鼠标点击的位置
                int px = pos.X;
                int py = pos.Y;
                newLabel = new Label();
                newLabel.Size = new System.Drawing.Size(11, 12);               
                    newLabel.Name = "newLabel";
                    newLabel.BackColor = Color.Blue;
                    newLabel.Location = new Point(px - 6, py + 4);
                    pictureBox1.Controls.Add(newLabel);
                    preCd = new PreCeDianControl();
                    preCd.Location = new Point(px + 8, py + 4);
                    preCd.Name = "";
                    preCd.Text = "12";
                    pictureBox1.Controls.Add(preCd);
   
                isAdd = false;
                isMoveUp = true;
            }
        }