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

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -