mathmax

Hello,

I've a strenge bug that occurs at runtime (i.e when I execute the .docx directly)
I've a worddocument project (word 2007) in which I've added a button. When the user click on the button a form is shown :

private void button1_Click(object sender, EventArgs e)
{
Form1 f = new Form1();
f.Show();
f.BringToFront();
}


In this form, I've just added a combobox. When the form loads, some items are added to the combobox:

public Form1()
{
InitializeComponent();
comboBox1.Items.Add("customer 1");
comboBox1.Items.Add("customer 2");
}

If I execute that in debug mode from Visual Studio, all work fine : a click on the button will show the form with the combobox filled with the two items.
But if I execute the .docx directly, a click on the button will show the form, but the combobox will have no item in it. In fact, the combobox seems to be disabled : it is transparent and a click on it will do nothing...

Have a look at this screenshot : http://www.orkos.com/tests/combo.jpg


Do you know why How to correct this

Thank you in advance for help.

mathmax



Re: Visual Studio Tools for Office controls on my form don't work.

Ji Zhou – MSFT

Hi Mathmax,

I tried the following steps, but cannot reproduce your issue. If there is any difference between our steps, please feel free to tell me.

1. Create a Word Document project using Visual Studio 2008 Beta 2.

2. Add a Windows Form Item in the project named Form1.cs

3. Drag a button named button1 on the document. Double click the button to go to the Code View, and copy your codes in my button1_Click function.

4. Drag a ComboBox on Form1, and copy your codes to Form1’s constructor.

5. Run the project. Click the button1, and Form1 shows up and ComboBox on it works OK.

6. Close the Visual Studio 2008. Go to the debug directory of my project. Double click the document to open it. Click button1, and Form1 also shows up with ComboBox’s right appearing.

So I think this is not a common issue to everyone since it cannot be reproduced in my side. In fact, I have met another problem about the ComboBox’s DrawItem event in Outlook Add In. I think maybe they have some relation. You can have a look at this thread:

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=2003039&SiteID=1

As to that problem, it’s fixed by show the form in another thread. So I suggest you use the following codes to see if it will resolve the weird issue.

Code Snippet

private void button1_Click(object sender, EventArgs e)

{

Thread t = new Thread(ShowForm);

t.Start();

}

void ShowForm()

{

Form1 f = new Form1();

f.Show();

}

Please let me know if that helps.

Thanks

Ji