Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2005

Tip: Looking for answers? Try searching our database.

ListBox - is the a reason this doesn't work?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
EXdeveloper@gmail.com - 31 Jul 2005 14:37 GMT
Hi,

I'm using a ListBox to display objects of various classes. Most clases
are derived from a base class of mine. If I override ToString in these
classes, the listbox displays what I want.

BUT
I have another class that is derived from LinkedList.

Overriding ToString in this one does not give the expected result,
instead "(Collection)" is displayed in the ListBox.

(To clarify, writing out a string like
WriteLn("MyClass: " + myClassObj);
DOES give the expected result, so the ToString override is in place, it
is just not called when adding the object to the LB)

I can get around this by using the DisplayMember property, but it
annoys me that ToString works for some classes but not for others.

So, is there a reason why overriding ToString in
MyClass : LinkedList<Something> seems to do nothing when adding it to
the ListBox?

Thanks,
Mac
Lloyd Dupont - 31 Jul 2005 16:41 GMT
I guess it's just ListBox which behave differently for collection
sorry no solution....

Signature

There are 10 kinds of people in this world. Those who understand binary and
those who don't.

> Hi,
>
[quoted text clipped - 22 lines]
> Thanks,
> Mac

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.