Re: Drop event on a picture box
- From: "Alberto Poblacion" <earthling-quitaestoparacontestar@xxxxxxxxxxxxx>
- Date: Tue, 1 May 2007 10:17:18 +0200
"Jeff Williams" <jeff.williams_NO_SPAM@xxxxxxxxxxxxxxx> wrote in message news:133dne0cceqpib5@xxxxxxxxxxxxxxxxxxxxx
I have several picture boxes on a form. I want to be able to drag pictures to this picture box. On the Drop how can I tell which picture box I am dropping the picture on. Te picture Box control name or control text would suit my needs.
Are you using a single DragDrop event for all your pictureboxes? In that case, the first argument, "sender", is a reference to the control that triggered the event, which is the picturebox in which you are dropping the picture. Since it is of type Object, you will have to cast it into PictureBox.
private void MyPictureBoxes_DragDrop(object sender, DragEventArgs e)
{
PictureBox dropTarget = sender as PictureBox;
if (dropTarget==null) return; //Should never happen
if (e.Data.GetDataPresent(typeof(Image))) {
Image item = (Image)e.Data.GetData(typeof(Image));
if (e.Effect == DragDropEffects.Copy ||
e.Effect == DragDropEffects.Move) {
dropTarget.Image = item;
}
}
}
.
- References:
- Drop event on a picture box
- From: Jeff Williams
- Drop event on a picture box
- Prev by Date: Re: C# or VB
- Next by Date: Re: Confused about proc vs. dynamic SQL vs LINQ
- Previous by thread: Drop event on a picture box
- Next by thread: XML datetime
- Index(es):
Relevant Pages
|