Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Windows Forms
  4. Drag and Drop Into Word

Drag and Drop Into Word

Scheduled Pinned Locked Moved Windows Forms
comgraphicshelpquestion
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Chadwick Posey
    wrote on last edited by
    #1

    I have all the code necessary (I think) to perform a drag and drop into word... but I am having trouble with pictures... any kind of Bitmap or Image does not drop properly into word, it does something but then acts as if I didn't drop anything it understood.... However, the same code works for dragging and dropping onto other office apps (e.g. Excel and Powerpoint). The code looks like this: private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { if (_mouseIsDown) { IDataObject obj = new DataObject(DataFormats.Bitmap, pictureBox1.Image); this.DoDragDrop(obj, DragDropEffects.All); } } Any one have any idea what I'm doing wrong? (and for the record, I have tried it without using IDataObject as well, just directly putting the image into the data argument... oh and I also tried creating a "new Bitmap(pictureBox1.Image)" and putting that in the data argument... To no avail.... A) Can anyone reproduce the issue at hand B) Does anyone know what I'm doing wrong? Do I need to use OLE directly or something? Thanks Chadwick Posey

    ============================= I'm a developer, he's a developer, she's a developer, we're developers, Wouldn't ya like to be a developer too?

    C 1 Reply Last reply
    0
    • C Chadwick Posey

      I have all the code necessary (I think) to perform a drag and drop into word... but I am having trouble with pictures... any kind of Bitmap or Image does not drop properly into word, it does something but then acts as if I didn't drop anything it understood.... However, the same code works for dragging and dropping onto other office apps (e.g. Excel and Powerpoint). The code looks like this: private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { if (_mouseIsDown) { IDataObject obj = new DataObject(DataFormats.Bitmap, pictureBox1.Image); this.DoDragDrop(obj, DragDropEffects.All); } } Any one have any idea what I'm doing wrong? (and for the record, I have tried it without using IDataObject as well, just directly putting the image into the data argument... oh and I also tried creating a "new Bitmap(pictureBox1.Image)" and putting that in the data argument... To no avail.... A) Can anyone reproduce the issue at hand B) Does anyone know what I'm doing wrong? Do I need to use OLE directly or something? Thanks Chadwick Posey

      ============================= I'm a developer, he's a developer, she's a developer, we're developers, Wouldn't ya like to be a developer too?

      C Offline
      C Offline
      Chadwick Posey
      wrote on last edited by
      #2

      Welp this is as close as I could figure out. You cannot do it directly in memory (as far as I can tell), but here is the code emulating something close to dragging and dropping a file from explorer into word: string[] files = new string[1]; files[0] = @"C:\someimage.jpg"; IDataObject d = new DataObject(); d.SetData(DataFormats.FileDrop, files); if (this.DoDragDrop(d, DragDropEffects.Copy) == DragDropEffects.Copy) { //your drop succeeded } Still cannot figure out why I cannot just drag and drop an image directly though.... would love to know what I could do differently.

      ============================= I'm a developer, he's a developer, she's a developer, we're developers, Wouldn't ya like to be a developer too?

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups