开发者

Having troubles color coding items in a listbox/listview/multiline textbox

开发者 https://www.devze.com 2022-12-12 10:01 出处:网络
I have an application that works similar to a chat, except beside the location where they submit their message they also have a dropdown that selects the type of message it is.

I have an application that works similar to a chat, except beside the location where they submit their message they also have a dropdown that selects the type of message it is.

When someone sends a message the message appears in a listbox (can also be a listview or a multiline textbox if that would work easier for what开发者_Python百科 I want to do). What I need to happen is that the message they submit needs to be color coded based on what message type they chose in the dropdown.

Does anyone know how to make list items be different colors?

Thanks,

Matt


If you don't want to draw the items yourself then use a ListView.

You'll need to set it into either a List or Details mode (in Details mode you'll need to add a column). Then you can add items to the list and set the background or foreground colors. See ListViewItem


Look into drawing the items yourself by subscribing to the DrawItem event and drawing each entry yourself. You can use the TextRenderer class to draw strings that don't look like crap (instead of using Graphic's implementation).

More information can also be found here.

0

精彩评论

暂无评论...
验证码 换一张
取 消