Strange behaviour using Drag and Drop in word 2003 automation in headers

Posted by Oliver Hanappi on Stack Overflow See other posts from Stack Overflow or by Oliver Hanappi
Published on 2010-03-18T07:13:44Z Indexed on 2010/03/19 7:01 UTC
Read the original article Hit count: 393

Filed under:
|
|
|
|

Hi!

I am developing a template based addin for Word 2003 which allows the user to drag and drop elements from a listbox into the word document. Unfortunately I'm getting a really strange behaviour when trying to drop elements in the document's header.

  1. Open the template and type something in the header
  2. Close the header and insert some content on the page
  3. Add a page break.
  4. Switch to page layout mode where and set zoom level to "Two Pages"
  5. Open the header
  6. Slowly Drag and Drop an list item from the list box to the header.
  7. See multiple Page Setups dialogs occur which cause Word to crash.

Here is my code:

// in ThisDocument.cs

public MyUserControl _control;
public void Init()
{
    _control = new MyUserControl();
    ActionsPane.Controls.Add(_control);
    ActionsPane.Visible = true;
}

// in MyUserControl.cs

public void listBox1_MouseDown(object sender, MouseEventArgs e)
{
    DoDragDrop("something", DragDropEffects.Copy);
}

Have I done somethinkg wrong with implementing Drag and Drop? Is there a workaround for this strange behaviour?

Thanks in advance,
Oliver Hanappi

© Stack Overflow or respective owner

Related posts about c#

Related posts about vsto