By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,524 Members | 1,519 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,524 IT Pros & Developers. It's quick & easy.

Format Text of a ComboBox with DropDownStyle "DropDown"

P: n/a
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!
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi,

You will have to create a new control which inhertits from the
combobox. Here are some examples.
http://www.onteorasoftware.com/ComboBox.aspx

Ken
----------------
<f> wrote in message news:uv**************@TK2MSFTNGP11.phx.gbl...
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!

Nov 20 '05 #2

P: n/a
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.

<f> wrote in message news:uv**************@TK2MSFTNGP11.phx.gbl...
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!

Nov 20 '05 #3

P: n/a
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.
"Eran Amitai" <er********@hotmail.com> schrieb im Newsbeitrag
news:OZ**************@TK2MSFTNGP11.phx.gbl...
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.

<f> wrote in message news:uv**************@TK2MSFTNGP11.phx.gbl...
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!


Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.