开发者

Winform customize listbox item

I have开发者_运维问答 a listbox that should display data that contains 2 fields: time and a message. Instead of displaying 1 line of text, I want each item to be displayed as 2 lines - 1st line is the time and the 2nd line is the message, where each line has a different style.

How can I do this? I can bind the object array to the listbox, but how do I style it? Thanks for your answers.


I'll just formally post an answer earlier left in a comment. You'll need to use the DrawMode property, there's a good example of a DrawItem event handler in the MSDN Library article. You can draw the text any way you like, including drawing two lines of text. Use a large Font or set the ItemHeight property with DrawMode = OwnerDrawVariable to give yourself enough space for two lines.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜