且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

移动在运行时创建的控件

更新时间:2023-12-06 14:57:28

更改控件的Location属性.


1.如果在面板中创建文本框和标签,则可以直接移动面板而不是移动文本框和标签.由于面板是容器控件.

2.您可以将面板位置"更改为鼠标位置的适配器,例如:

1. If you create the textboxes and the labels in the panel, then you can move the panel directly rather than moving the textboxes and labels. Since the panel is a container control.

2. You can change the Location of panel to adapter to the mouse position, such as:

protected override void OnMouseMove(MouseEventArgs e)
{
    this.panel1.Location = new Point(e.X, e.Y);

    base.OnMouseMove(e);
}