Raven Dreamer
Raven Dreamer

Reputation: 7140

Drawing Items in a Listbox

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

When I'm drawing 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)

Upvotes: 0

Views: 167

Answers (1)

jsmith
jsmith

Reputation: 7278

Just test the objects for their type.

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

Upvotes: 1

Related Questions