Romain Vailleux

Hello there !

I am building an application based on Outlook 2007 and VSTO 2005 SE and I encounter an unexpected problem : an Office Listbox control placed manually on a outlook custom form through the Outlook 2007 form editor doesn't appear when the form render during the application running. But, it seems to be instanciated and to be contained correctly in the form : I can use it, add some stuff to it, but nothing never appears, although the others controls of different types work perfectly !

However, I've noticed that the listbox appears randomly under XP, never under Windows Server 2003 x64 and sometimes under Windows Vista... That behavior seems to be hazardous and I can't find a way to determine a logic and fix ou walkaround the bug !

I have to add that my form region is called thanks to an XML manifest refering to the addin where Outlook can get the form content. That form content is embeded in my project resources and return by the classical GetFormRegionStorage method implemented from the FormRegionStartup interface.

Does Someone have already seen these sort of strange behavior with Outlook/Office controls

If you have any idea on a way to follow my researches on this oddity, any comment would be very helpful !

Regards,

Romain Vailleux




Re: Visual Studio Tools for Office ListBox does not appear on my Form Region

Sue Mosher - Outlook MVP

I'm not sure what you mean by an Office Listbox control. On a form region, you should be using the new olkListBox control that comes with Outlook 2007.





Re: Visual Studio Tools for Office ListBox does not appear on my Form Region

Graphtyrael

Hi Sue,

Thanks for your comment !

I'm going to clarify the point you highlighted previously : actually you are totally right, I am using the new olkListBox control in my code to implement the logic behind my form. "Office Listbox" control, in my words, was to describe the control I inserted in my outlook form, from the new Office Outlook 2007 Controls library (not from the Microsoft Form 2.0 control library).

The big strange thing is that every controls of the Outlook 2007 Library works very well without the listBox (even the comboBox which is almost the same except the graphic display) !

Romain Vailleux






Re: Visual Studio Tools for Office ListBox does not appear on my Form Region

Sue Mosher - Outlook MVP

It might be helplful if you showed the code you're using to work with the list box.





Re: Visual Studio Tools for Office ListBox does not appear on my Form Region

Graphtyrael

Here is some picture to illustrate my case :

Editor View :

http://www.box.net/shared/gp5abt5muo

Item View :

http://www.box.net/shared/zjrhjx8yda






Re: Visual Studio Tools for Office ListBox does not appear on my Form Region

Sue Mosher - Outlook MVP

I was interested in seeing the code you're using to set the rows for the list box. Also, do you have it set to size autoamtically





Re: Visual Studio Tools for Office ListBox does not appear on my Form Region

Graphtyrael

That's the mecanism in the GetFormRegionStorage Method (my form resource is called "AssoContactForm") :

GetFormRegionStorage

switch (FormRegionName)

{

//If our form is called

case "AssoContactForm":

//We return the form loaded in the resources of the assembly

byte[] ofsBytes = Properties.Resources.AssoContactForm;

return ofsBytes;

default:

return null;

}

That is the code which implement the Outlook.olkListBox from the form. It is located in a class instanciated when Outlook call the BeforeFormRegionShow method of the Outlook.FormRegionStartup interface :

Code

//Get the control from the Outlook form

Outlook.OlkListBox listBoxNomsContact = ((Microsoft.Vbe.Interop.Forms.UserForm)FormRegion.Form).Controls.Item("ListBoxNomsContact") as Outlook.OlkListBox;

//Declare a change event

eventLstChangeTemp = new Microsoft.Office.Interop.Outlook.OlkListBoxEvents_ChangeEventHandler(listBoxNomsContact_Change);

//Subscribe to the change event

listBoxNomsContact.Change += eventLstChangeTemp;

As I said before, I do not try to add dynamically some control to the form region, only get the controls from an existing form and implement the logic.

I have no compilation error and methods called after an event on other control, like an olkButton are working well!

Thank for your attention Sue !

Romain Vailleux






Re: Visual Studio Tools for Office ListBox does not appear on my Form Region

Graphtyrael

Nothing in my code modificate the rows of my listBox... Is it necessary to set a row to see the listBox apprears






Re: Visual Studio Tools for Office ListBox does not appear on my Form Region

Sue Mosher - Outlook MVP

The list box isn't going to be usable unless it contains rows for the user to select from, so maybe Outlook hides it.





Re: Visual Studio Tools for Office ListBox does not appear on my Form Region

Graphtyrael

Oh ! Im going to look for something that way !

Thanks !

Romain Vailleux






Re: Visual Studio Tools for Office ListBox does not appear on my Form Region

Graphtyrael

Some piece of clue :
- If I publish a custom form with a listBox on the page 2 for exemple, the listBox appears on the form during its execution. So it is not due to a lack of library or reason like that.

- The listBox from Microsoft Forms 2.0 library doesn't appears either.

Other thing : I can't find a way to add a row to the listBox! No method, no collection... In fact, I think that maybe olkListBox control can only contain a single row with String items in it.

It is said in its MSDN description :

GetItem Method : Obtains a String that represents an item at the specified location in the list.

(http://msdn2.microsoft.com/en-us/library/bb176712.aspx)

Thanks for your help Sue !

Do not hesitate to ask for more information !

Romain Vailleux




Re: Visual Studio Tools for Office ListBox does not appear on my Form Region

Sue Mosher - Outlook MVP

AddItem and RemoveItem would be the methods to use to manage the row list.





Re: Visual Studio Tools for Office ListBox does not appear on my Form Region

Graphtyrael

Sue,

I've just noticed my misunderstanding about the word "rows" (a simple word isn't it...)... My thinking was on the columns and you were saying that the fact there were no columns in my listbox was the reason why nothing appear! Shame on me !

So, sure I know these methods (sorry again...) !

In fact, the listbox is well instanciated in my form and I can access to it, write and read its content, like a "normal" listBox. I made a test of adding an item into this listbox but nothing to do, it doesn't want to render in spite of the fact there is some items in the collection !

One more piece of clue :

The listBox appears only the first time the form is called by outlook, and only the first time on a new clean installation of Outlook... And from then, nothing can make it appear again (that sounds like a horror story...in fact it is, believe me !!)

Romain Vailleux






Re: Visual Studio Tools for Office ListBox does not appear on my Form Region

Sue Mosher - Outlook MVP

So, it does render, but only the first time the add-in runs and the form shows Are other parts of the add-in working OK If not, then have you checked the disabled items list





Re: Visual Studio Tools for Office ListBox does not appear on my Form Region

Graphtyrael

You're exactly right : it renders only the first time the form is instanciated and never after, even if Outlook shuts down!

I made another test :

- Closed Outlook

- Closed my current addin project :

- Removed the value from the registry representing the path to my current addin form region file (.ofs)

- Opened an old test addin VS project on region form.

- Put the correct registry value.

- Ran it in debug mode.

- Opened the appointement item containing the form for the 1st ==> the listbox in the form region appears and reacts !

--> the addin is in the enabled items list

- Close the item.

- Open it again and again ==> the listbox never appears again but the logic is running (I click a button on the form region and the message box appears) !

--> the addin is still in the enabled items list

- Closed the item.

- Closed Outlook.

- Closed my test addin project.

- Removed the value of the registry key.

- Opened my current addin project

- Put the correct registry value value.

- Ran it in debug mode.

- Made some manipulation ==> it works !

- Opened the appointement item containing the form for the 1st time==> the listbox in the form region appears and reacts !

--> the addin is in the enabled items list

- Close the item.

- Open it again and again ==> the listbox never appears again but the logic is running (I click a button on the form region and the message box appears) !

--> the addin is still in the enabled items list

I'm sure you can understand my dismay !

Maybe it could help to know that my region form manifest is configured to make it appears on an adjoining mode.

I checked in the complement option menu and the disabled stuff list : unfortunately, my addin is in the active addin list !