1
在表單上我有多個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;
}
WinForms或WPF? – Guy
有WinForms – Viva