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

C# random value from dictionary and tuple -

cgi - How do I interpret URLs without extension as files rather than missing directories in nginx? -

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