c# - id's and object names listbox -


i have listbox want populate contactpersoon objects created. user completes little form few textfields , when user presses ok button contactpersoon object created.

the problem want add name property of contactpersoon object listbox item. when want delete listbox want delete id property of object not name property...

can me this. tried using dictonaries didn't them work properly.

can please advise/help me this?

thank much..

btw iam sorry bad englisch :p

you need override tostring method in contactperson class. instance:

public class contactperson {     public string name;     public string id;      public override string tostring()     {         return name;     } } 

then, can add actual contactperson objects list box. instance:

listbox.items.add(contactperson); 

then, when delete, can loop through each item in list , read of properties of contactperson object, such as:

foreach(object item in listbox.items) {     if((contactperson)item.id == ...)     {         // work     } } 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -