I have a listbox that i want to populate with contactpersoon objects that i created.
The user completes a little form with a few textfields and when the user presses the ok button the contactpersoon object will be created.
The problem is now that i want to add the name property of the contactpersoon object to the listbox as an item. but when i want to delete it from the listbox i want to delete it by the id property of the object not the name property…
Can anyone help me with this. I tried using dictonaries but i didn’t get them to work properly.
Can anyone please advise/help me with this?
Thank you very much..
BTW Iam sorry for my bad englisch :p
You need to override the ToString method in the ContactPerson class. For instance:
Then, you can add the actual ContactPerson objects to your list box. For instance:
Then, when you delete, you can loop through each item in the list and read any of the properties of the ContactPerson object, such as: