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