au3scr Posted January 4, 2009 Share Posted January 4, 2009 (edited) I need a little help with listview.Sorry for my bad english, I hope wrote that topic enough clear,if not then ask questions. I had no Idea how to write that topic and then I decided to wrie it thatway you see it now also let me know if that topic is impolite...then I can learn from my mistakes.Its really hard for me so I need any kind of help, even few words can be helpful.1) How to automatically resize ListView columns to autofit text in "Program Name" colimn2)How I should code my "filter" button.I want use it thatway if I type keyword in the input then it shows only listviw items that contains word I typed in inputbox2nd point seems impossible for me, What are the steps? 1 step is get text from input, but I have no idea what to do next how i can tell listview to display only items that contain given keywords?anyone can reccomend me keywords i should look from help?expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Include <GuiListView.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 1024, 800, 150, 85, BitOR($WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_SYSMENU,$WS_CAPTION,$WS_OVERLAPPEDWINDOW,$WS_TILEDWINDOW,$WS_POPUP,$WS_POPUPWINDOW,$WS_GROUP,$WS_TABSTOP,$WS_BORDER,$WS_CLIPSIBLINGS)) GUICtrlSetResizing(-1, $GUI_DOCKBORDERS) $input = GUICtrlCreateInput("",125,1,125,20) $filterButton = GUICtrlCreateButton ("Filter",250,1) $ListView1 = GUICtrlCreateListView("Program Name|Program State|Program Descripton", 8, 72, 1009, 609, BitOR($LVS_REPORT,$LVS_SINGLESEL,$LVS_SHOWSELALWAYS,$WS_HSCROLL,$WS_VSCROLL), BitOR($WS_EX_CLIENTEDGE,$LVS_EX_SUBITEMIMAGES,$LVS_EX_TRACKSELECT,$LVS_EX_GRIDLINES)) $item1 = GUICtrlCreateListViewItem("Solid Edge|Not Installed|Solid Edge is a 3D CAD parametric feature solid modeling software.", $ListView1) $item2 = GUICtrlCreateListViewItem("AutoIt|Installed|AutoIt (pronounced aw-tow-it)[1] is a freeware automation language for Microsoft Windows.", $ListView1) GUISetState(@SW_SHOW) $button = GUICtrlCreateButton ("Get program name",1,1,120,20) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $button _GetProgramName() Case $filterButton EndSwitch WEnd Func _GetProgramName() $sel=_GUICtrlListView_GetSelectedIndices($ListView1,True) If $sel[0]=0 then Return; exit if none is selected $sName=_GUICtrlListView_GetItemText($ListView1,$sel[1],0);Get 0th column text MsgBox(0,"",$sName,-1,$Form1) EndFunc Edited January 4, 2009 by au3scr Link to comment Share on other sites More sharing options...
Achilles Posted January 4, 2009 Share Posted January 4, 2009 (edited) For 1 look at GUICtrlSetResizing... For 2 Loop through each item in your listview and check the text to see if it matches what the input has. You'll use StringInStr, _GUICtrlListView_GetItemTextString... Probably some other stuff.. Edited January 4, 2009 by Ichigo My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
rasim Posted January 4, 2009 Share Posted January 4, 2009 au3scr 1) How to automatically resize ListView columns to autofit text in "Program Name" colimn_GUICtrlListView_SetColumnWidth($hListView, 0, $LVSCW_AUTOSIZE) 2)How I should code my "filter" buttonExample: expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiListView.au3> Global $aLVItems[4][2] $aLVItems[0][0] = 3 $aLVItems[1][1] = "Notepad|For text writing" $aLVItems[2][1] = "WordPad|For text writing (advanced)" $aLVItems[3][1] = "Paint|Image making" $hGUI = GUICreate("Test", 330, 200) $cListView = GUICtrlCreateListView("Program|Description", 10, 10, 310, 140) For $i = 1 To $aLVItems[0][0] $aLVItems[$i][0] = GUICtrlCreateListViewItem($aLVItems[$i][1], $cListView) Next $cInput_Filter = GUICtrlCreateInput("", 11, 167, 140, 20) $cButton_Filter = GUICtrlCreateButton("Filter", 160, 166, 75, 23) $cButton_All = GUICtrlCreateButton("All", 246, 166, 75, 23) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $cButton_Filter _FilterItem(GUICtrlRead($cInput_Filter)) Case $cButton_All _ShowAll() EndSwitch WEnd Func _FilterItem($sText) If ($sText = "") Or (_GUICtrlListView_FindText($cListView, $sText) = -1) Then Return Local $i GUICtrlSendMsg($cListView, $LVM_DELETEALLITEMS, 0, 0) For $i = 1 To $aLVItems[0][0] If StringInStr($aLVItems[$i][1], $sText) Then $aLVItems[$i][0] = GUICtrlCreateListViewItem($aLVItems[$i][1], $cListView) Next EndFunc ;==>_FilterItem Func _ShowAll() If GUICtrlSendMsg($cListView, $LVM_GETITEMCOUNT, 0, 0) = $aLVItems[0][0] Then Return Local $i GUICtrlSendMsg($cListView, $LVM_DELETEALLITEMS, 0, 0) For $i = 1 To $aLVItems[0][0] $aLVItems[$i][0] = GUICtrlCreateListViewItem($aLVItems[$i][1], $cListView) Next EndFunc ;==>_ShowAll Link to comment Share on other sites More sharing options...
au3scr Posted January 4, 2009 Author Share Posted January 4, 2009 (edited) Thanks alot how to make that filter work thatway it dont have to type full neme ,It would be nice if I type "pad" and then it shows Notepad and Wordpad both Edited January 4, 2009 by au3scr Link to comment Share on other sites More sharing options...
BugFix Posted January 4, 2009 Share Posted January 4, 2009 (edited) Change this function like following: Func _FilterItem($sText) If ($sText = "") Then Return Local $strNew = '' For $i = 1 To $aLVItems[0][0] If StringInStr(_GUICtrlListView_GetItemText($cListView, $i-1), $sText) Then $strNew &= '$aLVItems['&$i&'][0] = GUICtrlCreateListViewItem($aLVItems['&$i&'][1], $cListView)' & @LF Next If $strNew = '' Then Return _GUICtrlListView_DeleteAllItems($cListView) Local $aExecute = StringSplit($strNew, @LF) For $i = 1 To UBound($aExecute) -1 Execute($aExecute[$i]) Next EndFunc ;==>_FilterItem Edited January 4, 2009 by BugFix Best Regards BugFix  Link to comment Share on other sites More sharing options...
yucatan Posted January 2, 2011 Share Posted January 2, 2011 Hello guys. i have some questions based on this topic and based on this code. i wanne make that i can search on all columns. so 3 colums and 3 inputfields if possible. if i typ something in field one. that it goed live search so filter right away. that i dont have to press a search button. if i backspace the field to i make it emty. that i get the orginal again. this is my code. expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiListView.au3> Global $aLVItems[4][2] $aLVItems[0][0] = 3 $aLVItems[1][1] = "Notepad|For text writing|data1" $aLVItems[2][1] = "WordPad|For text writing (advanced)|data1" $aLVItems[3][1] = "Paint|Image making|data1" $hGUI = GUICreate("Test", 330, 200) $cListView = GUICtrlCreateListView("data1|data2|data3", 10, 10, 310, 140) For $i = 1 To $aLVItems[0][0] $aLVItems[$i][0] = GUICtrlCreateListViewItem($aLVItems[$i][1], $cListView) Next $cInput_Filter = GUICtrlCreateInput("", 11, 167, 140, 20) $cButton_Filter = GUICtrlCreateButton("Filter", 160, 166, 75, 23) $cButton_All = GUICtrlCreateButton("All", 246, 166, 75, 23) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $cButton_Filter _FilterItem(GUICtrlRead($cInput_Filter)) Case $cButton_All _ShowAll() EndSwitch WEnd Func _FilterItem($sText) If ($sText = "") Then Return Local $strNew = '' For $i = 1 To $aLVItems[0][0] If StringInStr(_GUICtrlListView_GetItemText($cListView, $i -1 ), $sText) Then $strNew &= '$aLVItems['&$i&'][0] = GUICtrlCreateListViewItem($aLVItems['&$i&'][1], $cListView)' & @LF Next If $strNew = '' Then Return _GUICtrlListView_DeleteAllItems($cListView) Local $aExecute = StringSplit($strNew, @LF) For $i = 1 To UBound($aExecute) -1 Execute($aExecute[$i]) Next EndFunc ;==>_FilterItem Func _ShowAll() If GUICtrlSendMsg($cListView, $LVM_GETITEMCOUNT, 0, 0) = $aLVItems[0][0] Then Return Local $i GUICtrlSendMsg($cListView, $LVM_DELETEALLITEMS, 0, 0) For $i = 1 To $aLVItems[0][0] $aLVItems[$i][0] = GUICtrlCreateListViewItem($aLVItems[$i][1], $cListView) Next EndFunc ;==>_ShowAll Link to comment Share on other sites More sharing options...
Zedna Posted January 2, 2011 Share Posted January 2, 2011 (edited) if i typ something in field one. that it goed live search so filter right away. that i dont have to press a search button. if i backspace the field to i make it emty. that i get the orginal again. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> GuiCreate("",400,300) $input1=GuiCtrlCreateInput("",10,10,200,20) GuiSetState() GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") While 1 $msg=GuiGetMsg() If $msg=-3 Then Exit Wend Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam) Local $nNotifyCode = _HiWord($wParam) Local $nID = _LoWord($wParam) If $nID = $input1 And $nNotifyCode = $EN_CHANGE Then ConsoleWrite('Editchanged: ' & GUICtrlRead($input1) & @CRLF) EndIf Return $GUI_RUNDEFMSG EndFunc Func _HiWord($x) Return BitShift($x, 16) EndFunc Func _LoWord($x) Return BitAND($x, 0xFFFF) EndFunc Edited January 2, 2011 by Zedna Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
yucatan Posted January 3, 2011 Share Posted January 3, 2011 (edited) Hello Zenda, Thanks for ur code. i have been working on this. and this is what i have now. expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> Global $aLVItems[4][2] $aLVItems[0][0] = 3 $aLVItems[1][1] = "Notepad|For text writing|data1" $aLVItems[2][1] = "WordPad|For text writing (advanced)|data2" $aLVItems[3][1] = "Paint|Image making|data3" $hGUI = GUICreate("Test", 330, 300) $cListView = GUICtrlCreateListView("", 10, 110, 310, 140) _GUICtrlListView_InsertColumn($cListView, 0, "Column 1", 100) _GUICtrlListView_InsertColumn($cListView, 1, "Column 2", 100) _GUICtrlListView_InsertColumn($cListView, 2, "Column 3", 100) For $i = 1 To $aLVItems[0][0] $aLVItems[$i][0] = GUICtrlCreateListViewItem($aLVItems[$i][1], $cListView) Next $cInput_Filter1 = GUICtrlCreateInput("", 11, 80, 61, 20) $cInput_Filter2 = GUICtrlCreateInput("", 80, 80, 130, 20) $cInput_Filter3 = GUICtrlCreateInput("", 220, 80, 50, 20) ;$cButton_Filter = GUICtrlCreateButton("Filter", 160, 266, 75, 23) ;$cButton_All = GUICtrlCreateButton("All", 246, 266, 75, 23) GUISetState() GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") While 1 $msg=GuiGetMsg() If $msg=-3 Then Exit Wend Func _FilterItem($filter1,$filter2,$filter3) ConsoleWrite($filter1 & " "& $filter2& " "& $filter3&@CRLF) If ($filter1 = "") Then _ShowAll() If ($filter2 = "") Then _ShowAll() If ($filter3 = "") Then _ShowAll() Local $strNew = '' For $i = 1 To $aLVItems[0][0] If StringInStr(_GUICtrlListView_GetItemText($cListView, $i - 1 ), $filter1) Then $strNew &= '$aLVItems['&$i&'][0] = GUICtrlCreateListViewItem($aLVItems['&$i&'][1], $cListView)' & @LF Next For $i = 1 To $aLVItems[0][0] If StringInStr(_GUICtrlListView_GetItemText($cListView, $i -1,1), $filter2) Then $strNew &= '$aLVItems['&$i&'][0] = GUICtrlCreateListViewItem($aLVItems['&$i&'][1], $cListView)' & @LF Next For $i = 1 To $aLVItems[0][0] If StringInStr(_GUICtrlListView_GetItemText($cListView, $i -1,2), $filter3) Then $strNew &= '$aLVItems['&$i&'][0] = GUICtrlCreateListViewItem($aLVItems['&$i&'][1], $cListView)' & @LF ConsoleWrite($strNew&@CRLF) Next If $strNew = '' Then Return _GUICtrlListView_DeleteAllItems($cListView) Local $aExecute = StringSplit($strNew, @LF) For $i = 1 To UBound($aExecute) -1 Execute($aExecute[$i]) Next EndFunc ;==>_FilterItem Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam) Local $nNotifyCode = _HiWord($wParam) Local $nID = _LoWord($wParam) If $nID = $cInput_Filter1 And $nNotifyCode = $EN_CHANGE Then ;ConsoleWrite('Editchanged1: ' & GUICtrlRead($cInput_Filter1) & @CRLF) _filteritem(GUICtrlRead($cInput_Filter1),GUICtrlRead($cInput_Filter2),GUICtrlRead($cInput_Filter3)) EndIf If $nID = $cInput_Filter2 And $nNotifyCode = $EN_CHANGE Then ;ConsoleWrite('Editchanged2: ' & GUICtrlRead($cInput_Filter2) & @CRLF) _filteritem(GUICtrlRead($cInput_Filter1),GUICtrlRead($cInput_Filter2),GUICtrlRead($cInput_Filter3)) EndIf If $nID = $cInput_Filter3 And $nNotifyCode = $EN_CHANGE Then ;ConsoleWrite('Editchanged3: ' & GUICtrlRead($cInput_Filter3) & @CRLF) _filteritem(GUICtrlRead($cInput_Filter1),GUICtrlRead($cInput_Filter2),GUICtrlRead($cInput_Filter3)) EndIf Return $GUI_RUNDEFMSG EndFunc Func _ShowAll() If GUICtrlSendMsg($cListView, $LVM_GETITEMCOUNT, 0, 0) = $aLVItems[0][0] Then Return Local $i GUICtrlSendMsg($cListView, $LVM_DELETEALLITEMS, 0, 0) For $i = 1 To $aLVItems[0][0] $aLVItems[$i][0] = GUICtrlCreateListViewItem($aLVItems[$i][1], $cListView) Next EndFunc ;==>_ShowAll Func _HiWord($x) Return BitShift($x, 16) EndFunc Func _LoWord($x) Return BitAND($x, 0xFFFF) EndFunc it works (a part of it) but i cant combine 2 or 3 searches. Edited January 3, 2011 by yucatan Link to comment Share on other sites More sharing options...
yucatan Posted January 17, 2011 Share Posted January 17, 2011 Somebody? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 17, 2011 Moderators Share Posted January 17, 2011 yucatan, This code reacts as the inputs are changed, which is more normal than waiting until all 3 have something in them as yoru posted code does: expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> Global $aLVItems[4][2] $aLVItems[0][0] = 3 $aLVItems[1][1] = "Notepad|For text writing|data1" $aLVItems[2][1] = "WordPad|For text writing (advanced)|data2" $aLVItems[3][1] = "Paint|Image making|data3" $hGUI = GUICreate("Test", 330, 300) $cListView = GUICtrlCreateListView("", 10, 110, 310, 140) _GUICtrlListView_InsertColumn($cListView, 0, "Column 1", 60) _GUICtrlListView_InsertColumn($cListView, 1, "Column 2", 130) _GUICtrlListView_InsertColumn($cListView, 2, "Column 3", 50) For $i = 1 To $aLVItems[0][0] $aLVItems[$i][0] = GUICtrlCreateListViewItem($aLVItems[$i][1], $cListView) Next $cInput_Filter1 = GUICtrlCreateInput("", 11, 80, 55, 20) $cInput_Filter2 = GUICtrlCreateInput("", 71, 80, 125, 20) $cInput_Filter3 = GUICtrlCreateInput("", 221, 80, 45, 20) $hButton = GUICtrlCreateButton("Clear", 275, 80, 40, 20) GUISetState() GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton GUICtrlSetData($cInput_Filter1, "") GUICtrlSetData($cInput_Filter2, "") GUICtrlSetData($cInput_Filter3, "") EndSwitch WEnd Func _FilterItem($filter1, $filter2, $filter3) ConsoleWrite($filter1 & " " & $filter2 & " " & $filter3 & @CRLF) Local $aNewFilter[1][2] = [[0]] For $i = 1 To $aLVItems[0][0] $aSplit = StringSplit($aLVItems[$i][1], "|") If ($filter1 = "" Or StringInStr($aSplit[1], $filter1)) And _ ($filter2 = "" Or StringInStr($aSplit[2], $filter2)) And _ ($filter3 = "" Or StringInStr($aSplit[3], $filter3)) Then $aNewFilter[0][0] += 1 ReDim $aNewFilter[$aNewFilter[0][0] + 1][2] $aNewFilter[$aNewFilter[0][0]][1] = $aLVItems[$i][1] EndIf Next _GUICtrlListView_DeleteAllItems($cListView) iF $aNewFilter[0][0] = 0 Then Return For $i = 1 To $aNewFilter[0][0] GUICtrlCreateListViewItem($aNewFilter[$i][1], $cListView) Next EndFunc ;==>_FilterItem Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam) Local $nNotifyCode = _HiWord($wParam) Local $nID = _LoWord($wParam) If $nNotifyCode = $EN_CHANGE Then Switch $nID Case $cInput_Filter1, $cInput_Filter2, $cInput_Filter3 _filteritem(GUICtrlRead($cInput_Filter1), GUICtrlRead($cInput_Filter2), GUICtrlRead($cInput_Filter3)) EndSwitch EndIf Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_COMMAND Func _ShowAll() If GUICtrlSendMsg($cListView, $LVM_GETITEMCOUNT, 0, 0) = $aLVItems[0][0] Then Return Local $i GUICtrlSendMsg($cListView, $LVM_DELETEALLITEMS, 0, 0) For $i = 1 To $aLVItems[0][0] $aLVItems[$i][0] = GUICtrlCreateListViewItem($aLVItems[$i][1], $cListView) Next EndFunc ;==>_ShowAll Func _HiWord($x) Return BitShift($x, 16) EndFunc ;==>_HiWord Func _LoWord($x) Return BitAND($x, 0xFFFF) EndFunc ;==>_LoWord 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  Link to comment Share on other sites More sharing options...
guinness Posted January 17, 2011 Share Posted January 17, 2011 Nice ListView Example UDF List:  _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
tmazot007 Posted August 30, 2011 Share Posted August 30, 2011 yucatan, This code reacts as the inputs are changed, which is more normal than waiting until all 3 have something in them as yoru posted code does: expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> Global $aLVItems[4][2] $aLVItems[0][0] = 3 $aLVItems[1][1] = "Notepad|For text writing|data1" $aLVItems[2][1] = "WordPad|For text writing (advanced)|data2" $aLVItems[3][1] = "Paint|Image making|data3" $hGUI = GUICreate("Test", 330, 300) $cListView = GUICtrlCreateListView("", 10, 110, 310, 140) _GUICtrlListView_InsertColumn($cListView, 0, "Column 1", 60) _GUICtrlListView_InsertColumn($cListView, 1, "Column 2", 130) _GUICtrlListView_InsertColumn($cListView, 2, "Column 3", 50) For $i = 1 To $aLVItems[0][0] $aLVItems[$i][0] = GUICtrlCreateListViewItem($aLVItems[$i][1], $cListView) Next $cInput_Filter1 = GUICtrlCreateInput("", 11, 80, 55, 20) $cInput_Filter2 = GUICtrlCreateInput("", 71, 80, 125, 20) $cInput_Filter3 = GUICtrlCreateInput("", 221, 80, 45, 20) $hButton = GUICtrlCreateButton("Clear", 275, 80, 40, 20) GUISetState() GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton GUICtrlSetData($cInput_Filter1, "") GUICtrlSetData($cInput_Filter2, "") GUICtrlSetData($cInput_Filter3, "") EndSwitch WEnd Func _FilterItem($filter1, $filter2, $filter3) ConsoleWrite($filter1 & " " & $filter2 & " " & $filter3 & @CRLF) Local $aNewFilter[1][2] = [[0]] For $i = 1 To $aLVItems[0][0] $aSplit = StringSplit($aLVItems[$i][1], "|") If ($filter1 = "" Or StringInStr($aSplit[1], $filter1)) And _ ($filter2 = "" Or StringInStr($aSplit[2], $filter2)) And _ ($filter3 = "" Or StringInStr($aSplit[3], $filter3)) Then $aNewFilter[0][0] += 1 ReDim $aNewFilter[$aNewFilter[0][0] + 1][2] $aNewFilter[$aNewFilter[0][0]][1] = $aLVItems[$i][1] EndIf Next _GUICtrlListView_DeleteAllItems($cListView) iF $aNewFilter[0][0] = 0 Then Return For $i = 1 To $aNewFilter[0][0] GUICtrlCreateListViewItem($aNewFilter[$i][1], $cListView) Next EndFunc ;==>_FilterItem Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam) Local $nNotifyCode = _HiWord($wParam) Local $nID = _LoWord($wParam) If $nNotifyCode = $EN_CHANGE Then Switch $nID Case $cInput_Filter1, $cInput_Filter2, $cInput_Filter3 _filteritem(GUICtrlRead($cInput_Filter1), GUICtrlRead($cInput_Filter2), GUICtrlRead($cInput_Filter3)) EndSwitch EndIf Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_COMMAND Func _ShowAll() If GUICtrlSendMsg($cListView, $LVM_GETITEMCOUNT, 0, 0) = $aLVItems[0][0] Then Return Local $i GUICtrlSendMsg($cListView, $LVM_DELETEALLITEMS, 0, 0) For $i = 1 To $aLVItems[0][0] $aLVItems[$i][0] = GUICtrlCreateListViewItem($aLVItems[$i][1], $cListView) Next EndFunc ;==>_ShowAll Func _HiWord($x) Return BitShift($x, 16) EndFunc ;==>_HiWord Func _LoWord($x) Return BitAND($x, 0xFFFF) EndFunc ;==>_LoWord M23 I want load my data and use filter but I don't know do it. Somebody help me . Thank you very much. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 30, 2011 Moderators Share Posted August 30, 2011 tmazot007, I want load my data and use filterWhat data and what filter? If you want help you have to give us some idea of what you want. Please try and explain in more detail what you are trying to do. 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  Link to comment Share on other sites More sharing options...
tmazot007 Posted August 30, 2011 Share Posted August 30, 2011 (edited) tmazot007, What data and what filter? If you want help you have to give us some idea of what you want. Please try and explain in more detail what you are trying to do. M23 My code expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ListviewConstants.au3> #include <GuiListView.au3> #include <EditConstants.au3> #include <ScreenCapture.au3> #include <GuiMenu.au3> #include <WinAPI.au3> #Include <File.au3> #include <Array.au3> #Region ### START Koda GUI section ### $GUI_Main = GUICreate(" ", 955, 521, 192, 124) $G_Add = GUICtrlCreateGroup("ADD", 8, 8, 249, 121) $L_1 = GUICtrlCreateLabel("Columns 1", 16, 24, 53, 17) $L_2 = GUICtrlCreateLabel("Columns 2", 16, 48, 53, 17) $L_3 = GUICtrlCreateLabel("Columns 3", 16, 72, 53, 17) $L_4 = GUICtrlCreateLabel("Columns 4", 16, 96, 53, 17) $I_1 = GUICtrlCreateInput("", 72, 24, 177, 21) $I_2 = GUICtrlCreateInput("", 72, 48, 177, 21) $I_3 = GUICtrlCreateInput("", 72, 72, 177, 21) $I_4 = GUICtrlCreateInput("", 72, 96, 177, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $Listview = GUICtrlCreateListView("", 260, 13, 682, 470) _GUICtrlListView_AddColumn(-1,"Columns 1",210) _GUICtrlListView_AddColumn(-1,"Columns 2",210) _GUICtrlListView_AddColumn(-1,"Columns 3",160) _GUICtrlListView_AddColumn(-1,"Columns 4",90) $G_Search = GUICtrlCreateGroup("Search", 10, 144, 249, 97) $L_F_1 = GUICtrlCreateLabel("F_Col 1", 18, 160, 40, 17) $L_F_2 = GUICtrlCreateLabel("F_Col 2", 18, 184, 40, 17) $L_F_3 = GUICtrlCreateLabel("F_Col 3", 18, 208, 40, 17) $I_F_1 = GUICtrlCreateInput("", 74, 160, 177, 21) $I_F_2 = GUICtrlCreateInput("", 74, 184, 177, 21) $I_F_3 = GUICtrlCreateInput("", 74, 208, 177, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $B_Add = GUICtrlCreateButton("Add", 88, 248, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Func Add() $1 = GUICtrlRead($I_1) $2 = GUICtrlRead($I_2) $3 = GUICtrlRead($I_3) Local $4 If GUICtrlRead($I_4) = "" Then $4 = "NULL" Else $4 = GUICtrlRead($I_4) EndIf If $1 = "" Or $2 = "" Or $3 = "" Then MsgBox(0,"Error","Error") Else GUICtrlCreateListViewItem($1 & "|" & $2 & "|" & $3 & "|" & $4,$Listview) EndIf EndFunc While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $B_Add Add() EndSwitch WEnd After I add data. I want use code filter, find data Edited August 30, 2011 by tmazot007 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 30, 2011 Moderators Share Posted August 30, 2011 tmazot007. I think this does what you want: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ListviewConstants.au3> #include <GuiListView.au3> #include <EditConstants.au3> #include <ScreenCapture.au3> #include <GuiMenu.au3> #include <WinAPI.au3> #include <File.au3> #include <Array.au3> Global $aLVItems[1] = [0] $GUI_Main = GUICreate(" ", 955, 521, 192, 124) GUICtrlCreateLabel("Columns 1", 16, 24, 53, 17) GUICtrlCreateLabel("Columns 2", 16, 48, 53, 17) GUICtrlCreateLabel("Columns 3", 16, 72, 53, 17) GUICtrlCreateLabel("Columns 4", 16, 96, 53, 17) $I_1 = GUICtrlCreateInput("", 72, 24, 177, 21) $I_2 = GUICtrlCreateInput("", 72, 48, 177, 21) $I_3 = GUICtrlCreateInput("", 72, 72, 177, 21) $I_4 = GUICtrlCreateInput("", 72, 96, 177, 21) $Listview = GUICtrlCreateListView("", 260, 13, 682, 470) _GUICtrlListView_AddColumn(-1, "Columns 1", 210) _GUICtrlListView_AddColumn(-1, "Columns 2", 210) _GUICtrlListView_AddColumn(-1, "Columns 3", 160) _GUICtrlListView_AddColumn(-1, "Columns 4", 90) GUICtrlCreateLabel("F_Col 1", 18, 160, 40, 17) GUICtrlCreateLabel("F_Col 2", 18, 184, 40, 17) GUICtrlCreateLabel("F_Col 3", 18, 208, 40, 17) $I_F_1 = GUICtrlCreateInput("", 74, 160, 177, 21) $I_F_2 = GUICtrlCreateInput("", 74, 184, 177, 21) $I_F_3 = GUICtrlCreateInput("", 74, 208, 177, 21) $B_Add = GUICtrlCreateButton("Add", 88, 248, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $B_Add Add() EndSwitch WEnd Func Add() $1 = GUICtrlRead($I_1) $2 = GUICtrlRead($I_2) $3 = GUICtrlRead($I_3) Local $4 If GUICtrlRead($I_4) = "" Then $4 = "NULL" Else $4 = GUICtrlRead($I_4) EndIf If $1 = "" Or $2 = "" Or $3 = "" Then MsgBox(0, "Error", "Error") Else GUICtrlCreateListViewItem($1 & "|" & $2 & "|" & $3 & "|" & $4, $Listview) $aLVItems[0] += 1 ReDim $aLVItems[$aLVItems[0] + 1] $aLVItems[$aLVItems[0]] = $1 & "|" & $2 & "|" & $3 & "|" & $4 GUICtrlSetData($I_1, "") GUICtrlSetData($I_2, "") GUICtrlSetData($I_3, "") GUICtrlSetData($I_4, "") EndIf EndFunc ;==>Add Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam) Local $nNotifyCode = _HiWord($wParam) Local $nID = _LoWord($wParam) If $nNotifyCode = $EN_CHANGE Then Switch $nID Case $I_F_1, $I_F_2, $I_F_3 _filteritem(GUICtrlRead($I_F_1), GUICtrlRead($I_F_2), GUICtrlRead($I_F_3)) EndSwitch EndIf Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_COMMAND Func _FilterItem($filter1, $filter2, $filter3) Local $aNewFilter[1] = [0] For $i = 1 To $aLVItems[0] $aSplit = StringSplit($aLVItems[$i], "|") If ($filter1 = "" Or StringInStr($aSplit[1], $filter1)) And _ ($filter2 = "" Or StringInStr($aSplit[2], $filter2)) And _ ($filter3 = "" Or StringInStr($aSplit[3], $filter3)) Then $aNewFilter[0] += 1 ReDim $aNewFilter[$aNewFilter[0] + 1] $aNewFilter[$aNewFilter[0]] = $aLVItems[$i] EndIf Next _GUICtrlListView_DeleteAllItems($Listview) iF $aNewFilter[0] = 0 Then Return For $i = 1 To $aNewFilter[0] GUICtrlCreateListViewItem($aNewFilter[$i], $Listview) Next EndFunc ;==>_FilterItem Func _HiWord($x) Return BitShift($x, 16) EndFunc ;==>_HiWord Func _LoWord($x) Return BitAND($x, 0xFFFF) EndFunc ;==>_LoWord Please ask if anything is unclear. 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  Link to comment Share on other sites More sharing options...
tmazot007 Posted August 30, 2011 Share Posted August 30, 2011 Thanks M23 Link to comment Share on other sites More sharing options...
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