cheeroke

List with unsorted items

4 posts in this topic

Hi,

I am trying to get my list displayed in order I press button not in alphabeticall order. I modified example from here

Code below. What i want to achieve is to according to pressed button message been displayed in that order.

Currently no matter what button in what order I press it is always showing first button NO1 and than button NO2.

PLease help.

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

Example()

Func Example()
    Local $sMESSAGE = "The following buttons have been clicked"

    GUICreate("My GUI list") ; will create a dialog box that when displayed is centered

    Local $idAdd = GUICtrlCreateButton("Add1", 64, 32, 75, 25)
    Local $idAdd2 = GUICtrlCreateButton("Add2", 64, 52, 75, 25)
    Local $idClear = GUICtrlCreateButton("Clear", 64, 72, 75, 25)
    Local $idMylist = GUICtrlCreateList("buttons that have been clicked", 176, 32, 121, 97)
    GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling
    GUICtrlSetData(-1, $sMESSAGE)
    Local $idClose = GUICtrlCreateButton("my closing button", 64, 160, 175, 25)

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idAdd
                GUICtrlSetData($idMylist, " button No1|")
                Case $idAdd2
                GUICtrlSetData($idMylist, " button No2|")
            Case $idClear
                GUICtrlSetData($idMylist, "")
            Case $idClose
                MsgBox($MB_SYSTEMMODAL, "", "the closing button has been clicked", 2)
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

 

Share this post


Link to post
Share on other sites



cheeroke,

As explained in the Help file, GUICtrlCreateList has a number of default styles - one of which is $LBS_SORT. So you need to set the styles excluding that one:

Local $idMylist = GUICtrlCreateList("buttons that have been clicked", 176, 32, 121, 97, BitOr($WS_BORDER, $WS_VSCROLL))

Reading the Setting Styles tutorial in the Wiki will explain in more detail.

M23

 


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

@Melba23
Good advice with the
Setting Styles.
I would like to add my solution for his "problem".

 

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListBox.au3>

Example()

Func Example()
    Local $sMESSAGE = "The following buttons have been clicked"

    GUICreate("My GUI list") ; will create a dialog box that when displayed is centered

    Local $idAdd = GUICtrlCreateButton("Add1", 64, 32, 75, 25)
    Local $idAdd2 = GUICtrlCreateButton("Add2", 64, 52, 75, 25)
    Local $idClear = GUICtrlCreateButton("Clear", 64, 72, 75, 25)
    Local $idMylist = GUICtrlCreateList("buttons that have been clicked", 176, 32, 121, 97)
    GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling
    GUICtrlSetData(-1, $sMESSAGE)
    Local $idClose = GUICtrlCreateButton("my closing button", 64, 160, 175, 25)

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idAdd
                _GUICtrlListBox_InsertString($idMylist,"Test1",_GUICtrlListBox_GetCount($idMylist))
                Case $idAdd2
                _GUICtrlListBox_InsertString($idMylist,"Test2",_GUICtrlListBox_GetCount($idMylist))
            Case $idClear
                GUICtrlSetData($idMylist, "")
            Case $idClose
                MsgBox($MB_SYSTEMMODAL, "", "the closing button has been clicked", 2)
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

 

With <GuiListBox.au3> you got more possibilities and variations.
Read the wiki files and start with _GUICtrlListBox_GetCount so you will quickly understand how easy you can setup your listbox with those commands.


Enjoy =)

Edited by AndroidZero

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks for your guidance and help.

Edited by cheeroke

Share this post


Link to post
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