Aceguy Posted February 14, 2011 Posted February 14, 2011 Hi guys, looking to create a filter from the input box, and display results back into listview.. expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <ListViewConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #include<array.au3> #include <GuiTab.au3> #include <GuiListView.au3> Opt("GUIOnEventMode", 1) #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 625, 443, 192, 124) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize") GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize") GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore") $Input1 = GUICtrlCreateInput("Input1", 24, 32, 497, 21) GUICtrlSetOnEvent(-1, "Input1Change") $List1 = GUICtrlCreateListview("||", 48, 96, 457, 279) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSetOnEvent(-1, "List1Click") for $x =1 to 20 GUICtrlCreateListViewItem(Random(1,3,1)&"|"&Random(1,3,1),$list1) Next GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Sleep(100) WEnd Func Form1Close() Exit EndFunc Func Form1Maximize() EndFunc Func Form1Minimize() EndFunc Func Form1Restore() EndFunc Func Input1Change() dim $array[ _GUICtrlListView_GetItemCount($list1)+1] for $d=1 to _GUICtrlListView_GetItemCount($list1) $array[$d]=_GUICtrlListView_GetItemTextString($list1,$d) Next _ArrayDisplay($array) _GUICtrlListView_DeleteAllItems($list1) EndFunc Func List1Click() EndFunc [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock
Newb Posted February 15, 2011 Posted February 15, 2011 Whatta... O.o I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it.
Moderators Melba23 Posted February 15, 2011 Moderators Posted February 15, 2011 Aceguy, I am not altogether sure what you want to do - certainly your code snippet does not offer many clues. This is something I wrote a while ago to filter the contents of a list - is it the sort of thing you are looking for? expandcollapse popup#include <GUIConstantsEx.au3> #include <Array.au3> #Include <GuiListBox.au3> Global $hGUI, $hInput, $hList, $sPartialData, $asKeyWords[100] ; Create list full of random 12 character "words" Keywords() $hGUI = GUICreate("Example", 200, 400) $hInput = GUICtrlCreateInput("", 5, 5, 190, 20) $hList = GUICtrlCreateList("", 5, 30, 190, 325, BitOR(0x00100000, 0x00200000)) $hButton = GUICtrlCreateButton("Read", 60, 360, 80, 30) $hUP = GUICtrlCreateDummy() $hDOWN = GUICtrlCreateDummy() $hENTER = GUICtrlCreateDummy() GUISetState(@SW_SHOW, $hGUI) ; Set accelerators for Cursor up/down and Enter Dim $AccelKeys[3][2]=[["{UP}", $hUP], ["{DOWN}", $hDOWN], ["{ENTER}", $hENTER]] GUISetAccelerators($AccelKeys) $sCurr_Input = "" $iCurrIndex = -1 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hList $sChosen = GUICtrlRead($hList) If $sChosen <> "" Then GUICtrlSetData($hInput, $sChosen) Case $hButton If $sPartialData <> "" Then $sFinal = GUICtrlRead($hInput) If _ArraySearch($asKeyWords, $sFinal) > 0 Then MsgBox(0, "Chosen", $sFinal) EndIf EndIf Case $hUP If $sPartialData <> "" Then $iCurrIndex -= 1 If $iCurrIndex < 0 Then $iCurrIndex = 0 _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndIf Case $hDOWN If $sPartialData <> "" Then $iTotal = _GUICtrlListBox_GetCount($hList) $iCurrIndex += 1 If $iCurrIndex > $iTotal - 1 Then $iCurrIndex = $iTotal - 1 _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndIf Case $hENTER If $iCurrIndex <> -1 Then $sText = _GUICtrlListBox_GetText($hList, $iCurrIndex) GUICtrlSetData($hInput, $sText) $iCurrIndex = -1 _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndIf EndSwitch ; If input has changed, refill list with matching items If GUICtrlRead($hInput) <> $sCurr_Input Then CheckInputText() $sCurr_Input = GUICtrlRead($hInput) EndIf WEnd Func CheckInputText() $sPartialData = "|" ; Start with delimiter so new data always replaces old Local $sInput = GUICtrlRead($hInput) If $sInput <> "" Then For $i = 0 To 99 If StringInStr($asKeyWords[$i], $sInput) <> 0 Then $sPartialData &= $asKeyWords[$i] & "|" Next GUICtrlSetData($hList, $sPartialData) EndIf EndFunc ;==>CheckInputText Func Keywords() Local $sData For $i = 0 To 99 For $j = 1 To 12 $asKeyWords[$i] &= Chr(Random(65, 90, 1)) Next $sData &= $asKeyWords[$i] & "|" Next GUICtrlSetData($hList, $sData) $iCurrIndex = -1 _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndFunc ;==>Keywords Just enter random chars in the input and the list only displays those items which contain that particular string. If this is close to what you want, please let me know - we can work to tailor it more to your requirements. Newb, Useful contribution.....not! M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
John C. Posted April 28, 2011 Posted April 28, 2011 M23, I was searching for something else and found this post. You solve my problem too. Thank you! -JC
Autoseek Posted May 29, 2014 Posted May 29, 2014 Hi Melba23, I also wanted the express my appreciation for this "proof of concept". Thanks a lot! Autoseek
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now