Jump to content

ComboBox hide item if certain object selected


Timppa
 Share

Recommended Posts

Hello again!

I couldn't think any clearer title for this topic so I explain my problem:

What I want is a three different ComboBoxes. There is 3 names in it: Bob, Jane and Fred. Then there is a priority list like this:

1st priority: > ComboBox                  2nd priority: > ComboBox             3rd priority: > ComboBox

If I select Jane as first priority, it will DISAPPEAR from other combo boxes as well, since I cannot use Jane for first and second priority.

You get the idea? And the default combo box is "Not set", if I set the "Not set" from Jane, the Jane item will appear again in the other ComboBoxes. Also, if you press Confirm button and there is one "Not set" visible, it will show a message that you need to set priority. This is simple and I guess I can do on my own but need help to "hide" the already selected name.

Is this possible? I totally have no idea how to do this so I do not have any script for that. 

 

Thanks in advance! :)

Link to comment
Share on other sites

  • Moderators

@Timppa I would suggest you start with building your GUI. Below is a framework to get you started; look in the help file under GUICtrlCreateCombo to create your combo boxes. Once you have your own script written, even if it is not doing exactly what you want, post here and we will do our best to assist.

#include <GUIConstantsEx.au3>

    $hGUI = GUICreate("Test", 300, 300)
        GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
        EndSwitch
    WEnd

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

Timppa,

I got involved in updating combos depending on what had already been selected in this thread - take a look and see if it helps. Please ask if you have any questions about how I went about it.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

@Timppa I would suggest you start with building your GUI. Below is a framework to get you started; look in the help file under GUICtrlCreateCombo to create your combo boxes. Once you have your own script written, even if it is not doing exactly what you want, post here and we will do our best to assist.

#include <GUIConstantsEx.au3>

    $hGUI = GUICreate("Test", 300, 300)
        GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
        EndSwitch
    WEnd

 

JLogan, I have the GUI already, this section is another form from the main GUI. This form opens when I press "Advanced Options" button and the GUI has been made alredy, there is nothing particular script that would affect the priority script I would like to have. But thanks anyways! :)

 

 

Timppa,

I got involved in updating combos depending on what had already been selected in this thread - take a look and see if it helps. Please ask if you have any questions about how I went about it.

M23

Allright I checked that thread and it was quite hard to understand because the OP asked kind of different thing (well practically the same thing, but in more advanced way(or complicated :D )).

So far he wanted action for 7 different days, so that would be same for me but 3 different priorities.

So would it start with this, right?

Global $ComboArray[][] = [["Jane"],["Bob"],["Fred"]]

But I'm not sure which part of script "hides" the already selected items because that script is in my opinion too complicated. :blink:

 

Would this be it?

For $j = 1 + $k To 2 + $k
    $aChoreList[$j] = StringReplace($aChoreList[$j], "|" & $aChores[$i][0] & "|", "|")
Next

(That was copy pasted from the other topic)

 

Thanks in advance!

Link to comment
Share on other sites

  • Moderators

Timppa,

that script is in my opinion too complicated

Really? Here is a simple version for the case you describe, although it can be expanded to as many combos as you wish:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <GuiComboBox.au3>

; Array to hold combo ControlIDs
Global $aCombo[4] = [3]

; Array to hold combo data - only full list set for first combo, note leading |
Global $aData[4] = [3, "|Bob|Jane|Fred"]

$hGUI = GUICreate("Test", 500, 500)

; Create combos - set as read-only
For $i = 1 To $aCombo[0]
    $aCombo[$i] = GUICtrlCreateCombo("", (150 * $i) - 140, 10, 100, 20, $CBS_DROPDOWNLIST)
    ; Set a cuebanner to display if no selection made
    _GUICtrlComboBox_SetCueBanner($aCombo[$i], "Not set")
Next
; Load first combo with all data
GUICtrlSetData($aCombo[1], $aData[1])

; Create button to check if all combos set
$cCheck = GUICtrlCreateButton("Check", 10, 100, 80, 30)
GUICtrlSetState($cCheck, $GUI_FOCUS)

GUISetState()

While 1

    $iMsg = GUIGetMsg()
    Switch $iMsg

        Case $GUI_EVENT_CLOSE
            Exit
        Case $cCheck

            ; Set check flag
            $bCheck = True
            ; Loop through combos
            For $i = 1 To $aCombo[0]
                ; Get selection - if CueBanner displayed then no selection returned
                If GUICtrlRead($aCombo[$i]) = "" Then
                    ; Clear flag
                    $bCheck = False
                    ; No point in checking further
                    ExitLoop

                EndIf

            Next
            If $bCheck Then
                ; No empty combos
                MsgBox($MB_SYSTEMMODAL, "Correct", "All priorities set")
            Else
                ; At least one enpty combo
                MsgBox($MB_SYSTEMMODAL, "Error", "Please set all priorities")
            EndIf



        Case Else ; Must be a combo
            For $i = 1 To $aCombo[0] - 1 ; No need to do anything when final combo actioned

                If $iMsg = $aCombo[$i] Then
                    ; Read combo selection
                    $sSel = GUICtrlRead($aCombo[$i])
                    ; Take current combo selection with trailing "|", remove the selected item and then remove the trailing "|"
                    ; This is required in case one element is a subset of another
                    $aData[$i + 1] = StringTrimRight(StringReplace($aData[$i] & "|", "|" & $sSel & "|", "|"), 1)
                    ; Set the shortened data in the next combo
                    GUICtrlSetData($aCombo[$i + 1], $aData[$i + 1])
                    ; Empty all remaining combos
                    For $j = $i + 2 To $aCombo[0] - 1
                        GUICtrlSetData($aCombo[$j], "")
                    Next
                    ; No point in looping further
                    ExitLoop

                EndIf

            Next
    EndSwitch

WEnd

Is that clearer?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Ohh yes. That is more simplier version. I guess I got confused because there were so much more lines of script that I do not need and got totally confused but that script is in fact very easy to understand.

Thank you very much for the help! :) Also, I always try my best to build up my own scripts, but sometimes I run out of ideas since this language is so new to me :(

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...