tags:

views:

366

answers:

2

Hi i want to implement IListSource interface from c++. It contains 1 method GetList() and one property called ContainsListCollection.

How can i do this.how to set the property to false/true in c++

A: 

Here's how you do:

ref class ListSource : IListSource

{

static BindingList<String ^> ^list = gcnew BindingList<String ^>();

public:

property bool ContainsListCollection

{

virtual bool get() = IListSource::ContainsListCollection::get

{

return true;

}

}

virtual IList^ GetList() = IListSource::GetList

{

return gcnew ArrayList();

}

};
Schildmeijer
Why return a new ArrayList instead of your BindingList directly? That seems like an odd choice...
Reed Copsey
+1  A: 

This MSDN article contains an example implementation of IListSource in C#. It should be fairly straightforward from there to figure out how to do it in C++: msdn.microsoft.com/en-us/library/system.componentmodel.ilistsource.aspx (Add an http:// to that because I'm a new user.)

It looks like GetList() should return a new IList each time. If the IList that GetList() returns is a collection of ILists (how meta), then ContainsListCollection should be set to true, otherwise set it to false.

patjak