vb.net - Set Minimum Number in ComboBox -


i using line generate collection of numbers combobox.

main.combobox.items.addrange(enumerable.range(1, maxnum).select(function(s) s.tostring()).toarray()) 

i wondering how set minimum it? example, 6-100, instead of default 1-100.

update:

i using numbersetting value of 0 in project properties settings tab.

numbersetting getting actual value from:

my.settings.numbersetting = cint(combobox.text) 

once numbersetting has value, use maxnum set maximum number of options in combobox:

dim maxnum = my.settings.numbersetting     dim winners = enumerable.range(1, maxnum).orderby(function(r) rand.next()).take(5).toarray() 

this allows me 100 checkboxes if select 100 option combobox. looking set minimum option 6, 1, 2, 3, 4, , 5 not options in combobox.

solved:

private sub options_load(sender object, e eventargs) handles mybase.load     dim maxnum = my.settings.numbersetting2     numbercombo.items.addrange(enumerable.range(6, maxnum - 5).select(function(s) s.tostring()).toarray()) end sub 

where my.settings.numbersetting2 has default value of 100.

yes, can. however, notice arguments start , count (not max). thus, should adjust combobox initialization this:

dim minnum integer = 6 dim maxnum integer = 100 main.combobox.items.addrange(enumerable.range(minnum, maxnum - minnum + 1).select(function(s) s.tostring()).toarray()) 

note should change range(1, maxnum) range(minnum, maxnum - minnum + 1)

edit:

this how result of program be

before: there no item in combobox

enter image description here

the code: shows use of enumerable.range

enter image description here

after: shows result in combobox beginning after button click

enter image description here


if use right , have made sure clear previous combobox items, enumerable.range(minnum, maxnum - minnum + 1) should work fine.


edit 2:

if still have values after those, have hardcoded value in combobox. in case, maybe want check designer -> click on combobox -> check collection property. there might hardcoded values there. alternative, try implement combobox.items.clear() before adding items make sure cleared up.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -