C++/CLI How to I store Associated Data on ComboBox Item?

J

JEKATICH

How do I store associated data on a ComboBox item (ToolStripComboBox)?

The API and MFC has a (Set/Get)ItemData(Ptr), however, I do not see any such
animal in .NET.

Thanks

JEK
 
G

Guest

It seems that specific property has been taken away. See here for discussion
on VB, although I think it applies equally to C++/CLI if you ignore the stuff
about VB6:

http://support.microsoft.com/kb/311340

The way I would achieve this in C++/CLI is something like:

public ref class FooItem
{
private:
// my item data
public:
virtual String^ ToString() { /* return the text representation of the item
*/ }
};


mycombobox->Items->Add(gcnew FooItem);
 
J

JEKATICH

Great solution!!!

One smop:

virtual String^ ToString() override { /* return the text representation of
the item */ }

Thanks
JEK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top