Rama Krishna rao

Hi,
I need to display data in multiple columns (like in a table) in a form region.
I tried all Outlook.Olk* controls, none of them are suitable for my requirement.
Neither "Grid" control is supported for form regions.

1)Could you please suggest me any other way to show the data in multiple columns
2)How to get the handle to this control in the function BeforeFormRegionShow() so that I can populate the values to this control

Thanks.


Regards,
Rama





Re: Visual Studio Tools for Office Support for multiple columns in Form Region controls

Daniel Molina - MSFT

Hi,

Are you using VSTO for this project If so, you can add an Outlook Form Region to your add-in. They are based on Windows Forms so you can use DataGrid or any other .NET control.






Re: Visual Studio Tools for Office Support for multiple columns in Form Region controls

Sue Mosher - Outlook MVP

Only in Orcas can you add a .NET control to a form region. And if you do, it's .NET controls only, none off the Outlook-aware olk* controls.



Re: Visual Studio Tools for Office Support for multiple columns in Form Region controls

Daniel Molina - MSFT

Well, for Orcas Beta 2 you can expect support for managed form regions based on OFS files, so that would bring back olk* controls (but no Windows Forms + olk controls in the same region though).

If question is strictly referring to VSTO 2005 SE then yes, no support for Windows Forms controls in Outlook Form Regions.






Re: Visual Studio Tools for Office Support for multiple columns in Form Region controls

Sue Mosher - Outlook MVP

Right, that's my point: In Orcas, you either use .NET controls or you use an .ofs file with olk* controls, which can be bound to Outlook properties, but you can't mix and match them in the same region.

In VSTO 2005 SE, any ActiveX control in theory should work on a region page, but I've heard of people having some problems and it hasn't been done much, I imagine. I'd probably stick with the OlkListBox control if it were my project.





Re: Visual Studio Tools for Office Support for multiple columns in Form Region controls

Rama Krishna rao

Hi Sue,
I am using VSTO SE, Visual Studio 2005.
Since Orcas is still in beta, I am not in position to opt for it.

1) I added Windows Forms 2.0 List box controls to the form region.

2) In BeforeFormRegionShow() function,
a) I tried to receive it as Outlook.OlkListBox item as shown below . But its functionality is limited, it does NOT support multiple columns.

Code Snippet

Outlook.OlkListBox listBox = UserForm.Controls.Item("ListBox") as Outlook.OlkListBox;



b) Also, I tried to receive it as shown below. It returns null. I came to know that we must receive all the controls as Olk* .
Code Snippet

Microsoft.Vbe.Interop.Forms.ListBox winformListBox =

(Microsoft.Vbe.Interop.Forms.ListBox)UserForm.Controls.Item("ListBox");



Is my approach correct Is there any other approach for this
Thanks.

Regards,
Rama






Re: Visual Studio Tools for Office Support for multiple columns in Form Region controls

Sue Mosher - Outlook MVP

I checked with Ryan Gregg on the Outlook team about this. He says the solution is to add an MSForms 2.0 list box at runtime: "You can add the control dynamically at runtime in BeforeFormRegionShow, after setting a value on the FormRegion to disable control replacement." That would be the FormRegion.SuppressControlReplacement property. I haven't had a chance to try it, but it sounds promising.





Re: Visual Studio Tools for Office Support for multiple columns in Form Region controls

sgra

Hello,

I am also working on presenting the data from a recordset on a form region in the form of a grid.

When I drag and drop MSForms 2.0 controls , they get automatically replaced with outlook controls. I understand that I need to set FormRegion.SuppressControlReplacement to true. But where do I set this in the code

Also I tried using Microsoft Flex Grid Control in the form region to represent a table data from the record set. But I am new to Flex Grid control and do not know how to programatically populate the same in C#. Lots of googling didn't help. Also will this work on a Form Region to represent a data from a table

I am also trying to understand which is the best way to represent a recordset on a Form Region. Please let me know what is the best control to represent the data from a table.

Thanks
Ram






Re: Visual Studio Tools for Office Support for multiple columns in Form Region controls

Sue Mosher - Outlook MVP

Ram, as I said in my earlier post, Ryan recommends using the BeforeRegionShow event to set SuppressControlReplacement to True.

I doubt that there is any flex grid code in C#, since it's an ActiveX control. You'll probably need to learn from VB samples, like the one at http://www.pbdr.com/vbtips/gen/Article-UsingFlexGrids(1).htm. I have no idea whether Microsoft tested that control on a form region. Maybe it will work as you want it to; maybe not.





Re: Visual Studio Tools for Office Support for multiple columns in Form Region controls

sgra

Sue,

I tried all of these methods but still not been able to add multiple columns to a list control in a Form Region.

I tried the below approaches.

Approach 1.
--------------------

1. Added a Microsoft Form 2.0 ListBox control to the Form region and named it as List1.
2. In the Form region's BeforeFormRegionShow method I tried the following.

//using Forms = Microsoft.Vbe.Interop.Forms;

this.FormRegion = FormRegion;
this.FormRegion.SuppressControlReplacement = true;
this.UserForm = FormRegion.Form as UserForm;

Forms.ListBox lst1 = this.UserForm.Controls.Item("List1") as Forms.ListBox;

But in this case I get 'lst1' as null and hence can't do anything further. But instead of the above statement I tried

Outlook.OlkListBox lst1 = this.UserForm.Controls.Item("List1") as Outlook.OlkListBox;

In this case lst1 is NOT null and hence I am able to get the handle to the list control. But this being a Oulook listbox control, I do not get the multi column feature of Forms 2.0 list control.

I referred to Ryan Gregg's blog at
http://blogs.msdn.com/rgregg/archive/2007/06/21/mysterious-errors-when-using-form-regions-from-managed-code-add-ins.asp
where he is mentioning about similar problem and possible solution for the same. But I verified in my setup that I am referencing to the correct library.

Approach 2
----------------

As suggested by you , I tried adding a Microsoft Forms 2.0 control to the form region programatically. For adding the same I need to mention the 'Program ID' for the control as shown below.

//using Forms = Microsoft.Vbe.Interop.Forms;

Forms.UserForm form = FormRegion.Form as Forms.UserForm;
Forms.ListBox listBox = ( Forms.ListBox) form.Controls.Add( "<PROGRAM_ID>", "listBox1",true);

I do not know what needs to be put in place of <PROGRAM_ID> for Forms 2.0 ListBox control


Thanks
Ram





Re: Visual Studio Tools for Office Support for multiple columns in Form Region controls

Sue Mosher - Outlook MVP

I interpret Ryan's advice as meaning that any controls added before SuppressControlReplacement is set to True will be converted, including those in the .ofs file. Therefore, only Approach 2 would work, adding the control, after SuppressControlReplacement is set to True. For the ProgID, try "Forms.ListBox.1".





Re: Visual Studio Tools for Office Support for multiple columns in Form Region controls

sgra


I was able to add a new Microsoft.Vbe.Interop.Forms.ListBox control in a form region at run time. I want to add multiple columns for this listbox.

I do not have much information for Microsoft.Vbe.Interop.Forms.ListBox on implementing and populating multiple columns.

Is there any place to get more information about using Microsoft.Vbe.Interop.Forms.ListBox control

Thanks
Ram




Re: Visual Studio Tools for Office Support for multiple columns in Form Region controls

Sue Mosher - Outlook MVP

sgra, MSDN should have a reference for the MS Forms 2.0 library, but it's probably easier to access it through the object browser in any Office application's VBA editor, once you've added a form to VBA. It has the usual ColumnCount, List, Column properties; AddItem, RemoveItem methods that you'd expect.





Re: Visual Studio Tools for Office Support for multiple columns in Form Region controls

Rama Krishna rao

I am trying to add Windows.Forms.ListBox dynamically to a form region.

What should I enter in the place of PROGRAM_ID in the following statement

Windows.Forms.ListBox listBox = ( Windows.Forms.ListBox) form.Controls.Add( "<PROGRAM_ID>", "listBox",true);

Any idea where I can get program Ids of other controls

Thanks,

Rama







Re: Visual Studio Tools for Office Support for multiple columns in Form Region controls

Sue Mosher - Outlook MVP

Rama, It is not possible to add a .NET control to a form region in VSTO 2005 SE. You'll need Orcas -- Beta 2, I think. And it will have to be a region built completely in VS, not one that uses an .ofs file.

Or did you mean that you want to add an MS Forms 2.0 list box That would be Forms.ListBox.1, if the information in the article at http://support.microsoft.com/kb/238755 still applies.