4 Combos

Discussion in 'Questions (Windows Mobile)' started by PatrikL, Apr 28, 2009.

  1. PatrikL

    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: Apr 28, 2009
  2. klaus

    klaus Expert Licensed 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.
     
  3. PatrikL

    PatrikL Member Licensed User

    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.

    I know, this was only example.
     

    Attached Files:

  4. specci48

    specci48 Well-Known Member Licensed 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
     
  5. klaus

    klaus Expert Licensed User

    Hi specci48,

    While I was looking for a solution, I saw that you were faster than me.
    Good job.

    Best regards.
     
  6. PatrikL

    PatrikL Member Licensed User

    Thx, Timer works fine.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice