Combobox Using Wrong ToString Method

D

Don

I have a project wherein I derive a combobox and create a custom Populate()
method for it to fill it with objects of a custom class I also created in a
second project that the combobox project references. This custom class has
the ToString function overridden to display certain information.

Everything worked fine until one day the combobox started displaying
"AssemblyName.ClassName" (e.g. "MyProject.MyCustomClass") instead of the
appropriate value that the overridden ToString is supposed to return. It's
like the combobox is using the base Object.Tostring method instead of my
overridden one.

Sometimes the problem goes away after making unrelated changes in the
combobox project and then recompiling it a few times. However, it will
always suddenly stop working later on. I suspect this happens after
significant, yet completely unrelated, changes are made to the project that
contains the original custom class (even though the custom class itself is
untouched).

After fiddling around with stuff in the combobox propject it will randomly
start working again. Even when the temporary changes made in order to bring
about the random 'fix' are undone. Basically what I'm saying is that this
change in behavior appears to have nothing to do with the code for the
components involved.

This is just driving me crazy. None of the code that is involved in the
combobox or the class whose objects are used to populated are being modified
at all, yet it randomly stops working properly.

It sounds like someone else had a similar problem (
http://groups.google.ca/group/micro...bject.tostring"&rnum=1&hl=en#8635637a628db41f )
, though this is not exactly the same problem I am having

Has anyone experienced anything like this at all?

- Don

PS: I'm using the 1.1 framework on WinXP SP2 and am manually setting the
versions of all our projects (they have remained static throughout this). I
suspect a Microsft update is the culprit because this all started happening
after an automatic update was installed (not sure which, though). Yes I've
tried reinstalling the .NET framework.
 
T

tomb

I would highly recommned renaming the overriden toString method with
something more speciallized, as this kind of crap from Microsoft will
make you crazy. I have had similar things happen to me in XP that don't
happen in Win2K, so I do all my development on my Win2K box. XP is
still too buggy for me, and MS development tools are also. The combined
effect is killer!

T
 
D

Don

That's a good idea. I'll see if there's a way I can do this with the
combobox's DisplayMember property. Thanks.

- Don
 
D

Don

I spoke too soon. The control randomly started ignoring the DataMember
property and is now doing what it did before. Argh!

- Don
 
D

Don

Hmmm... I changed the function to be a readonly property instead and it
seems to be working.

How very odd. But at least it appears to work now!

- Don
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top