Re: Drop event on a picture box



"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;
}
}
}


.



Relevant Pages

  • Re: OLE Object- the real question
    ... Now you have a blank image control. ... Dim strFilename As String, strFind As String ... My file path for the 1st picture is ...
    (microsoft.public.access.forms)
  • Re: Using Image Acquisition Automation: how to display the thumbnail?
    ... I note that the Picture control in VB allows me to assign the image ... make sure it has been tested in VFP. ... >>access all of the items in the JPG file, including the thumbnail picture. ...
    (microsoft.public.fox.vfp.forms)
  • Re: Graphics in Report
    ... text1 on my report was a bound control named text1. ... I hope what you wrote actually translates to "change the picture ...
    (microsoft.public.access.reports)
  • RE: Adding Bound Pictures to an Access Database
    ... except in the case where I don't have a picture for a student. ... Dim strPath As String ... you have the Image control, not either of the Object controls. ... UI I'm not sure where you'll find it, but the Picture property should be ...
    (microsoft.public.access.modulesdaovba)
  • RE: Adding Bound Pictures to an Access Database
    ... except in the case where I don't have a picture for a student. ... Dim strPath As String ... you have the Image control, not either of the Object controls. ... UI I'm not sure where you'll find it, but the Picture property should be ...
    (microsoft.public.access.modulesdaovba)