【发布时间】:2013-03-22 06:23:40
【问题描述】:
在一个表单上,我有多个 usercontrols,它们会在每次点击 button 时动态创建。我希望用户能够选择它们以便复制删除等。就像我们用鼠标选择图标,然后删除它们。为此,我创建了另一个用户控件,它是在鼠标位置创建的。我不知道如何绘制该用户控件。到目前为止我的代码:
//method that creates usercontrols
private void _butttnAddControls_Click(object sender, EventArgs e)
{
TControl tcontrol = new TControl();
tcontrol.BringToFront();
}
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
SelectPanel pselect = new SelectPanel();//pselect is the control used to create the rectangle for selection
pselect.Visible = true;
Point p = PointToClient(Cursor.Position);
pselect.Location = p;
pselect.SelectionPanel = true;
this.Controls.Add(pselect);
}
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
pselect.Visible = false;
}
【问题讨论】:
标签: c# winforms user-controls controls