How do I get a unicode symbol/emoji to appear in a listbox in C#? -
the user can "lock" item on listbox prevent being altered. i'm trying symbol '🔒' (unicode 1f512) appear next item, keep getting square '◻'. appears in microsoft visual studio in editor, font consolas. changed font consolas in listbox, , tried number of other fonts, none of them worked.
it should work out of box default font microsoft sans serif
.
the following code works me. it's not production quality, proving point.
private void form1_load(object sender, eventargs e) { listbox1.items.add("🔒"); } private void buttonunlock_click(object sender, eventargs e) { listbox1.items[0] = listbox1.items[0].tostring().replace("🔒", ""); } private void buttonappend_click(object sender, eventargs e) { listbox1.items[0] += "🔒"; }
at first thought problem language/font settings if visual studio editor able show unicode characters correctly, doesn't seem case.
Comments
Post a Comment