c# - DevExpress RepositoryItemComboBox BackColor property ignored -
i have following code almost works properly;
private void cbstatus_drawitem(object sender, listboxdrawitemeventargs e) { string item = e.item string; if (item != null) { switch (item) { case "1": e.appearance.forecolor = color.green; e.appearance.backcolor = color.green; break; case "2": e.appearance.forecolor = color.orange; e.appearance.backcolor = color.orange; break; case "3": e.appearance.forecolor = color.red; e.appearance.backcolor = color.red; break; } } }
when dropdown shown, items forecolor correct, backcolor remains whatever backcolor of theme is; i.e. if i've got set dark theme, backcolor dark, cells in gridview, rather being green/orange/red.
i've tried setting e.appearance.options.usebackcolor
trying set e.handled
(e.handled
breaks forecolor too, got rid of that).
not sure why it's not working. ideas?
if set e.handled
true
must draw items yourself. example, can use appearanceobject.drawbackground
method , appearanceobject.drawstring
method draw items:
private void cbstatus_drawitem(object sender, listboxdrawitemeventargs e) { string item = e.item string; if (item != null) { switch (item) { case "1": e.appearance.backcolor = color.green; break; case "2": e.appearance.backcolor = color.orange; break; case "3": e.appearance.backcolor = color.red; break; } e.appearance.drawbackground(e.cache, e.bounds); e.appearance.drawstring(e.cache, item, e.bounds); e.handled = true; } }
Comments
Post a Comment