Windows Develop Bookmark and Share   
 index > Windows Forms General > how to add value and string to listbox
 

how to add value and string to listbox

i have one class (Exampleclass C)

C c = new C();

i only want to add c object, i can use listbox1.items.add(c);

but i want not only add c object into listbox, but string to. So in the listbox show the string (Example : try 1) when i click on the selected item in the listbox i can get the c object.

thank for your answer... :)

XeonYK  Monday, January 01, 2007 5:08 PM

Just overriding the ToString() method in your calass, you can change thedisplayname in the ListBox

E.g:

public class C
{
public override string ToString()
{
return "Anything You Like as Display Name";
}

}

Kusala  Monday, January 01, 2007 5:54 PM

Just overriding the ToString() method in your calass, you can change thedisplayname in the ListBox

E.g:

public class C
{
public override string ToString()
{
return "Anything You Like as Display Name";
}

}

Kusala  Monday, January 01, 2007 5:54 PM

You can use google to search for other answers

Custom Search

More Threads

• How to update Listbox items
• Need webBrowser to execute while app waits??
• Multiple Controls. TLayoutPanel
• BUG: MDI Child Icon on Main Menu when maximized
• TextBox and RadioButton Validation in Windows Form Application
• disabling MDI menu merge
• Burn MP3s to CD
• Is this equivalent event handling code
• How I Can Justify Text in Rchtextbox?
• upload download from FTP Server