4 Combos

PatrikL

Member
Licensed User
Hi,

I dont know how solve this problem:

I have 4 comboboxes cbx_thing0...cbx_thing3 . All have same items : "01","02","03","04","05"

Displaying all 4 comboboxes on the form. I need to change the list of items for each combo, so that it does not include items that are selected on other combos.

Example:
cbx_thing0 - selected "01" + in list "01" and "03"
cbx_thing1 - selected "04" + in list "03" and "04"
cbx_thing2 - selected "02" + in list "02" and "03"
cbx_thing3 - selected "05" + in list "03" and "05"

Combos must change everytime when is SelectionChanged. I dont have any idea how made it.

This code from me doesnt work.

Sub napln_kombo
For i = 0 To cisla
meno = "cbxcislo" & i
Control(meno,ComboBox).Clear
For j = 0 To 8
Control(meno,ComboBox).Add(nazvycisel(j).name)
Next j
Next i
End Sub

Sub kombo_SelectionChanged (Index, Value)
napln_kombo
For i = 0 To cisla
meno1 = "cbxcislo" & i
For j = 0 To cisla
meno2 = "cbxcislo" & j
If i <> j Then
Control(meno1,ComboBox).Remove(Control(meno2,ComboBox).Text)
End If
Next j
Next i
End Sub

Sorry for my english.
 
Last edited:

klaus

Expert
Licensed User
Longtime User
Sorry, but I don't understand what exactly you want to do ?
If you select "01" in cbxthing0, do you want to update the other comboboxes by removing the "01"
If then you select "03" in cbxthing1 you want to update the other comboboxes by removing "03" ?
If in cbxthing0 you change the selection to "02", what should the program do, add "01" again to the others, and remove "02" from them?

Could you please explain more in details your problem.

Be aware that cbx_thing0 is an invalid control name, underscores are not allowed!

Best regards.
 

PatrikL

Member
Licensed User
Could you please explain more in details your problem.

I try, but is hard to explain. I made simple example program.

I want select on each combo only free (not used on other combos) items.

I hope this is more clear.

Be aware that cbx_thing0 is an invalid control name, underscores are not allowed!
I know, this was only example.
 

Attachments

  • combos.sbp
    1.3 KB · Views: 189

specci48

Well-Known Member
Licensed User
Longtime User
Hello PatrikL,

the problem is that you try to change the entries of a combobox while processing the according SelectionChanged event.

The usual workaround is to activate a timer in the event subroutine and process your changes in a separate sub which is called by the timer.

I attached a fixed version of your example. :)


specci48
 
Top