vb.net - Bug in VSTO - Combobox in worksheet scrolling down with no reason -
take @ code below. code works perfectly, placing combobox @ cell a1, gives list of items.
dim sheet microsoft.office.tools.excel.worksheet dim sheet1 excel.worksheet = globals.thisaddin.application.activesheet sheet = globals.factory.getvstoobject(sheet1) dim combo new windows.forms.combobox() 'combo.autocompletemode = windows.forms.autocompletemode.suggestappend combo.autocompletesource = windows.forms.autocompletesource.listitems combo.items.addrange({"test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8", "test9", "test10", "test11", "test12", "test13", "test14", "test15", "test16", "test17", "test18", "test19", "test20", "test21", "test22", "test23", "test24", "test25", "test26", "test27", "test28", "test29", "test30", "test31", "test32", "test33", "test34"}) me.sheet.controls.addcontrol(combo, me.sheet.range("$a$1"), "test") the problem happens when uncomment code line sets autocompletemode suggestappend.
to see bug happening, need make list of items large enough scroll appears. then, click @ arrow (to open dropdown menu) , select first item of dropdown menu. again, scroll last element, , click @ one. repeat operation.
at second iteration doing this, should see bug. list scrolls automatically when press mouse button, changing element under cursor. then, when release mouse button, select item not desired element.
does knows workaround problem? i'm using vs2013, , programming vb.net (as can see, hehe).
thanks
the problem solved "jmierzej" here
solution:
i first added items dictionary object, , bound combobox dictionary. in below code, 'prefill' object dictionary object holds combobox contents.
'define dictionary hold values dim prefill = new dictionary(of string, string) 'add code here fill dictionary items. in case used identical values key/value pair in dictionary cbox.datasource = new bindingsource(prefill, nothing) cbox.displaymember = "value" cbox.valuemember = "key"
Comments
Post a Comment