开发者

how to change the background color of an item in a listbox when its string value is equal to something?

开发者 https://www.devze.com 2023-04-13 06:13 出处:网络
i have a listbox that contains the words \"week1\", \"week2\", ..... all the way up to \"week52\" and when i select a week from the listbox it will retrieve a value from a mysql database that will rep

i have a listbox that contains the words "week1", "week2", ..... all the way up to "week52" and when i select a week from the listbox it will retrieve a value from a mysql database that will represent a progress bar value. my progress bar has a range of 0-120 and i would like to have all the weeks that have values higher than 100 to be highlighted or marked somehow, in the listbox. so my question is, "is there a way to set the background color of certain weeks in the listbox to orange based on the value that they represent on the database?

for example for "week1", the value is 114, so when the listbox loads, i want the background color of the item "week1" in the list to be orange (indicating that it's current value is higher than 100)? i know that this requires me to implement a user defined drawing function for the listbox items but i dont know where i would even start. i would like this to be somewhat automatic so that it checks the values and changes the background colors of any value higher than 100, inst开发者_StackOverflow社区ead of me specifying a name of the item.

Thanks in advance!


I don't believe you can do this with a Listbox (at least not without creating your own implementation/subclassing/overriding/whatever of a Listbox).

Pretty sure you could do it with a ListView (in Detail mode), though, if that helps.

0

精彩评论

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