Question

I've created an owner-draw user control that inherits from ComboBox.

The control stores specialized items, but the Items collection still accepts and returns items of type Object. Any tips on the best way to override this collection to be type-safe?

About the only way I can think of is to create my own collection class. The class wouldn't be a true collection--it would take an ObjectCollection as an argument to the constructor and simply extend the methods of that to.

The user control would pass the original Items collection to the constructor of the new class. And then override the Items property to return an instance of the new class instead.

This seems somewhat convoluted. Is there a better way?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top