在运行时将控件添加到父控件

时间:2015-03-30 18:42:46

标签: c# winforms

我需要在运行时添加一个控件添加到父控件(面板) 我可以设置对象的属性(PictureEdit),但我如何显示它...添加到父控件??? 谢谢

protected override void OnPaint(PaintEventArgs pe)
{
        PictureEdit halfmoon = new PictureEdit();
        halfmoon.Location = new Point(36, 3);
        halfmoon.BorderStyle = BorderStyles.NoBorder;
        halfmoon.Properties.SizeMode = PictureSizeMode.Squeeze;
        halfmoon.Image = Properties.Resources.picture;
}

1 个答案:

答案 0 :(得分:0)

Panel_name.Controls.Add(halfmoon);