Reputation: 2075
On a form I have multiple usercontrols
which are created dynamically at every button
click. I want an user to be able to select them in order to copy delete,etc. Like we select with mouse, icons and then delete them. To do this,I created another usercontrol,that is created at mouse position. I don't know how can I draw that usercontrol. My code untill now:
//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;
}
Upvotes: 1
Views: 74
Reputation: 1423
If you are using WinForms you can use the Control's DrawToBitmap()
method to get an image of your usercontrol youv'e created dynamically.
Check this link for more information Control.DrawToBitmap Method
Then you can draw your all control array into a picture box, and use you Mouse Events there.
Upvotes: 1