Format Text of a ComboBox with DropDownStyle "DropDown"

G

Guest

Hello,
I try to format the text of a combobox with DropDownStyle "DropDown".
I just mean the text which is displayed when the combobox isn't touched.
Usually it displays the ToString() method of the SelectedItem. But I want to
override the it.
Overriding the ToString() of the class of the SelectedItem doesn't help
because I can't touch the class.
Maybe I have to rewrite the WndProc WM_PAINT.
Whatever, I just need an idea. ...
Thanks!
 
E

Eran Amitai

Why don't you use another class? I'm not sure I understand the problem, but
if I do, you could create a new class and have each object hold a reference
to an object of the other class you can't touch. When adding values to the
combobox, add objects of the new class. Then you have complete control over
the ToString implementation.
 
G

Guest

I dont want to implement tons of new classes.
All classes which will be displayed in the combobox have a string variable
"name". So I want to override the combobox text method and display the
"name" via reflection.
 

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