Re: Accessing outlook form controls.
- From: "Ken Slovak - [MVP - Outlook]" <kenslovak@xxxxxxxx>
- Date: Tue, 6 Feb 2007 09:22:27 -0500
You need to cast it to a control in the MS Forms 2.0 library, not to a Windows.Forms control. You should have a reference to that library so the properties, etc. of that ListBox are available to you.
The ListBox used in Outlook form controls doesn't have an Items collection, it has an AddItem method. All the items in the list are in the List collection. After adding that library reference use the Object Browser to see what's available to you for that control.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
"MeAgin" <MeAgain@xxxxxxxxx> wrote in message news:uh1C1RbSHHA.2212@xxxxxxxxxxxxxxxxxxxxxxx
Hi Eric,
Thanks for the info.
In my VB.NET code initially I tried to get the object to a variable with the
ListBox type not Object type as mentioned. That was giving an error and when
I defined the variable as an Object it is working.
When I checked the type is shown that the type of this object is
"System.__ComObject" even it is a ListBox in the mail form.
Now I want to add some items to the ListBox and when I try to add items to
the Items collection like,
oControl.Items.Add("Item1")
It doesn't add and giving and error.
"Public member 'Items' on type 'Control' not found."
Then I tried to cast the object to a ListBox as
oListBox = CType(oControl, ListBox)
But it failec with the message,
"Unable to cast COM object of type 'System.__ComObject' to class type
'System.Windows.Forms.ListBox'. Instances of types that represent COM
components cannot be cast to types that do not represent COM components;
however they can be cast to interfaces as long as the underlying COM
component supports QueryInterface calls for the IID of the interface."
I understand the message but how can I cast the object as an interface. My
requiremnent is to add some items to a list box in a mail form from my com
add-in.
Thanks.
Nadee
.
- References:
- Accessing outlook form controls.
- From: MeAgin
- Re: Accessing outlook form controls.
- From: MeAgin
- Accessing outlook form controls.
- Prev by Date: Re: vsto auto update security
- Next by Date: Re: vsto auto update security
- Previous by thread: Re: Accessing outlook form controls.
- Next by thread: Accessing outlook form controls.
- Index(es):
Relevant Pages
|