Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Binding Custom Collection to a Combobox in a User Control

Status
Not open for further replies.

Craig0201

Technical User
Oct 11, 2000
1,261
GB
Hi,

Long winded title I know but hey!

OK, i've got a custom collection of objects inherited from System.Collection.CollectionBase that is populated as an app opens and placed in a global variable.

As my form is opened, a property on the UserControl is passed the collection. As the property is set, the DataSource, DisplayMember and ValueMember on a combobox are set.

Now for the BUT.....

I'm using this technique on one control great but on another, it is displaying the name of the class stored in the collection, not the Name property on the object.

IDENTICAL CODE! And it works when I bind to a combobox on the form! What are I doing wrong before I go insane!!!!

Craig

PS All help appreciated!
 
Hi Craig,

I think I had the exact same problem - but with a listbox. I'll give you a quotation from MSDN:

The controls that inherit from ListControl can display diverse types of objects. If the specified property does not exist on the object or the value of DisplayMember is an empty string (""), the results of the object's ToString method are displayed instead.

Double check that the property exists on the object (spelled correctly, correct case?). (You already confirmed that the DisplayMember is set).

Hope this helps,
Marg

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top