开发者

Drawing Items in a Listbox

开发者 https://www.devze.com 2023-01-08 00:54 出处:网络
Assume I have a Listbox with two types of objects in it, either a String, or a custom class called \"Label\".

Assume I have a Listbox with two types of objects in it, either a String, or a custom class called "Label".

When I'm dr开发者_高级运维awing the items in the listbox, is there a way to determine whether to cast e as a string or "label"?

The functionality I'm looking for is so that the Strings show up as one color, and the Labels show up as another. (Part of the Label Class being that they have their own color value to be extracted and then used)


Just test the objects for their type.

if (e is String)
{
    //do something..
}
else if (e is Label)
{
    //do something..
}
0

精彩评论

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