c# - How to set focus on listbox item? -
i have defined list box this:
var listbox = new listbox(); listbox.items.add(1); listbox.items.add(2); listbox.items.add(3);
and want set focus directly item in listbox.
if this:
listbox.selectedindex = 0; listbox.focus();
the focus set entire listbox, if press arrow down move selection item below, have press arrow twice. first time focus jumps entire listbox first item, , when can press arrow again , selection jumps down.
i want set focus directly first item, don't have press arrow twice.
var listboxitem = (listboxitem)listbox.itemcontainergenerator.containerfromitem(listbox.selecteditem); listboxitem.focus();
Comments
Post a Comment