Sawboy Posted April 10, 2011 Share Posted April 10, 2011 I would say hello So my problem is the search function ... I've tried it out but he does not seek the names in the list view I hope I get help Thanks Translated with Google expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <GuiConstants.au3> Local $Gui = GUICreate("MyTool", 560, 360) $cInput_Searchstring = GUICtrlCreateInput("Suchwort,Blockname,Itemname", 5, 320, 235, 25) $cButton_Search = GUICtrlCreateButton("ID Suchen", 245, 320, 60, 25) $Button1 = GUICtrlCreateButton("Homepage", 430, 24, 100, 25) $Button2 = GUICtrlCreateButton("Exit", 430, 64, 100, 25) Local $tab = GUICtrlCreateTab(5, 5, 400, 300) Local $tab1 = GUICtrlCreateTabItem("Block IDs ") Local $hListView = GUICtrlCreateListView("IDs |Blockart |Findbarkeit", 10, 30, 389 , 270, -1, BitOR( $WS_EX_CLIENTEDGE, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES)) $ListView1_0 = GUICtrlCreateListViewItem("1|Stein|test", $hListView) $ListView1_0 = GUICtrlCreateListViewItem("2|Gras|test", $hListView) $ListView1_0 = GUICtrlCreateListViewItem("3|Erde|test", $hListView) $ListView1_0 = GUICtrlCreateListViewItem("4|Pflasterstein|test", $hListView) $ListView1_0 = GUICtrlCreateListViewItem("5|Holz|test", $hListView) $ListView1_0 = GUICtrlCreateListViewItem("6|Setzling|test", $hListView) $ListView1_0 = GUICtrlCreateListViewItem("7|Bedrock|test", $hListView) $ListView1_0 = GUICtrlCreateListViewItem("8|Wasser|test", $hListView) $ListView1_0 = GUICtrlCreateListViewItem("9|Stehendes Wasser|test", $hListView) $ListView1_0 = GUICtrlCreateListViewItem("10|Lava|test", $hListView) $ListView1_0 = GUICtrlCreateListViewItem("11|Stehendes Lava|test", $hListView) $ListView1_0 = GUICtrlCreateListViewItem("12|Sand|test", $hListView) $ListView1_0 = GUICtrlCreateListViewItem("13|Kies|test", $hListView) $ListView1_0 = GUICtrlCreateListViewItem("14|Golderz|test", $hListView) $ListView1_0 = GUICtrlCreateListViewItem("15|Eisenerz|test", $hListView) Local $tab2 = GUICtrlCreateTabItem("Item IDs ") Local $hListView2 = GUICtrlCreateListView("IDs |Itemart |Test", 10, 30, 389 , 270, -1, BitOR( $WS_EX_CLIENTEDGE, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES)) $ListView1_0 = GUICtrlCreateListViewItem("3|test|test", $hListView2) $ListView1_0 = GUICtrlCreateListViewItem("2|test|test", $hListView2) $ListView1_0 = GUICtrlCreateListViewItem("3|test|test", $hListView2) Local $tab3 = GUICtrlCreateTabItem("Commands") Local $hListView3 = GUICtrlCreateListView("IDs |Itemart |Test", 10, 30, 389 , 270, -1, BitOR( $WS_EX_CLIENTEDGE, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES)) $ListView1_0 = GUICtrlCreateListViewItem("1|test|test", $hListView3) $ListView1_0 = GUICtrlCreateListViewItem("3|test|test", $hListView3) $ListView1_0 = GUICtrlCreateListViewItem("6|test|test", $hListView3) Local $tab4 = GUICtrlCreateTabItem("Hilfe") _GUICtrlListView_RegisterSortCallBack($hListView) _GUICtrlListView_RegisterSortCallBack($hListView2) _GUICtrlListView_RegisterSortCallBack($hListView3) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _GUICtrlListView_UnRegisterSortCallBack($hListView) Exit Case $hListView _GUICtrlListView_SortItems($hListView, GUICtrlGetState($hListView)) Case $hListview2 _GUICtrlListView_SortItems($hListView2, GUICtrlGetState($hListView2)) Case $hListview3 _GUICtrlListView_SortItems($hListView3, GUICtrlGetState($hListView3)) EndSwitch Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _GUICtrlListView_Destroy($hListView) Exit Case $cButton_Search $aSearch = _SearchString(_GUICtrlListView_GetSelectedIndices($hListView), GUICtrlRead($cInput_Searchstring)) Switch @error Case 0 _GUICtrlEdit_SetSel($hListView, $aSearch[0] - 1, $aSearch[1] - 1) ControlFocus($hWnd, "", $hListView) Case 1 MsgBox(16, "Fehler", "Name wurde nicht gefunden.") Case 2 MsgBox(16, "Fehler", "Kein Suchwort eingegeben oder Textfeld leer.") EndSwitch EndSwitch WEnd Exit Func _SearchString($hListView, $sSearchString) If StringReplace($hListView, " ", "") = "" Or StringReplace($sSearchString, " ", "") = "" Then Return SetError(2, 0, 0) $iStringInStr = StringInStr($hListView, $sSearchString) If Not $iStringInStr Then Return SetError(1, 0, 0) Local $aReturn[2] = [$iStringInStr, $iStringInStr + StringLen($sSearchString)] Return $aReturn EndFunc Link to comment Share on other sites More sharing options...
Zibit Posted April 10, 2011 Share Posted April 10, 2011 So my problem is the search function ... I've tried it out but he does not seek the names in the list view Yes, the problem isnt inside the function, the problem is in the parameter's. Sometimes you have to think outside the function You need to change the _SearchString parameter. at the moment it isnt a string but an index for the array. take a look. Func _SearchString($hListView, $sSearchString) ConsoleWrite($hListView & @CRLF) If StringReplace($hListView, " ", "") = "" Or StringReplace($sSearchString, " ", "") = "" Then Return SetError(2, 0, 0) $iStringInStr = StringInStr($hListView, $sSearchString) If Not $iStringInStr Then Return SetError(1, 0, 0) Local $aReturn[2] = [$iStringInStr, $iStringInStr + StringLen($sSearchString)] Return $aReturn EndFunc Translated with Google Rookie mistake, it will only make things worse Hope i helped. Creator Of Xtreme DevelopersPixel Pattern UDFTray GUI UDFMathssend & recive register scriptMouse Control via Webcam Link to comment Share on other sites More sharing options...
Sawboy Posted April 10, 2011 Author Share Posted April 10, 2011 (edited) I did it but he does not seek I sit as long as the turn very hard for my head But thanks that you help me I know that the translator is not good Edited April 10, 2011 by Sawboy Link to comment Share on other sites More sharing options...
Sawboy Posted April 11, 2011 Author Share Posted April 11, 2011 Can any one help me please thanks Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 11, 2011 Moderators Share Posted April 11, 2011 (edited) Sawboy,If you use the UDF created ListViews you can use _GUICtrlListView_FindInText - but that means managing your own tabs:expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <GuiConstants.au3> $Gui = GUICreate("MyTool", 560, 360) $cInput_Searchstring = GUICtrlCreateInput("Suchwort,Blockname,Itemname", 5, 320, 235, 25) $cButton_Search = GUICtrlCreateButton("ID Suchen", 245, 320, 60, 25) $Button1 = GUICtrlCreateButton("Homepage", 430, 24, 100, 25) $Button2 = GUICtrlCreateButton("Exit", 430, 64, 100, 25) $tab = GUICtrlCreateTab(5, 5, 400, 300) $tab1 = GUICtrlCreateTabItem("Block IDs ") $hListView_1 = _GUICtrlListView_Create($Gui, "", 10, 30, 390, 270, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS, $LVS_SINGLESEL)) _GUICtrlListView_SetExtendedListViewStyle($hListView_1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES)) _GUICtrlListView_SetBkColor($hListView_1, 0xC4C4C4) _GUICtrlListView_SetTextBkColor($hListView_1, 0xC4C4C4) _GUICtrlListView_AddColumn($hListView_1, "IDs", 50) _GUICtrlListView_AddColumn($hListView_1, "BlockArt", 110) _GUICtrlListView_AddColumn($hListView_1, "FindBarkeit", 110) _GUICtrlListView_AddItem($hListView_1, "1") _GUICtrlListView_AddSubItem($hListView_1, 0, "Stein", 1) _GUICtrlListView_AddSubItem($hListView_1, 0, "test1", 2) _GUICtrlListView_AddItem($hListView_1, "2") _GUICtrlListView_AddSubItem($hListView_1, 1, "Gras", 1) _GUICtrlListView_AddSubItem($hListView_1, 1, "test2", 2) _GUICtrlListView_AddItem($hListView_1, "3") _GUICtrlListView_AddSubItem($hListView_1, 2, "Erde", 1) _GUICtrlListView_AddSubItem($hListView_1, 2, "test3", 2) _GUICtrlListView_AddItem($hListView_1, "4") _GUICtrlListView_AddSubItem($hListView_1, 3, "Pflasterstein", 1) _GUICtrlListView_AddSubItem($hListView_1, 3, "test4", 2) _GUICtrlListView_AddItem($hListView_1, "5") _GUICtrlListView_AddSubItem($hListView_1, 4, "Holz", 1) _GUICtrlListView_AddSubItem($hListView_1, 4, "test5", 2) _GUICtrlListView_AddItem($hListView_1, "6") _GUICtrlListView_AddSubItem($hListView_1, 5, "Setzling", 1) _GUICtrlListView_AddSubItem($hListView_1, 5, "test6", 2) _GUICtrlListView_AddItem($hListView_1, "7") _GUICtrlListView_AddSubItem($hListView_1, 6, "BedRock", 1) _GUICtrlListView_AddSubItem($hListView_1, 6, "test7", 2) _GUICtrlListView_AddItem($hListView_1, "8") _GUICtrlListView_AddSubItem($hListView_1, 7, "Wasser", 1) _GUICtrlListView_AddSubItem($hListView_1, 7, "test8", 2) _GUICtrlListView_AddItem($hListView_1, "9") _GUICtrlListView_AddSubItem($hListView_1, 8, "Stehendes Wasser", 1) _GUICtrlListView_AddSubItem($hListView_1, 8, "test9", 2) _GUICtrlListView_AddItem($hListView_1, "10") _GUICtrlListView_AddSubItem($hListView_1, 9, "Lava", 1) _GUICtrlListView_AddSubItem($hListView_1, 9, "test10", 2) _GUICtrlListView_AddItem($hListView_1, "11") _GUICtrlListView_AddSubItem($hListView_1, 10, "Stehendes Lava", 1) _GUICtrlListView_AddSubItem($hListView_1, 10, "test11", 2) _GUICtrlListView_AddItem($hListView_1, "12") _GUICtrlListView_AddSubItem($hListView_1, 11, "Sand", 1) _GUICtrlListView_AddSubItem($hListView_1, 11, "test12", 2) _GUICtrlListView_AddItem($hListView_1, "13") _GUICtrlListView_AddSubItem($hListView_1, 12, "Kies", 1) _GUICtrlListView_AddSubItem($hListView_1, 12, "test13", 2) _GUICtrlListView_AddItem($hListView_1, "14") _GUICtrlListView_AddSubItem($hListView_1, 13, "Golderz", 1) _GUICtrlListView_AddSubItem($hListView_1, 13, "test14", 2) _GUICtrlListView_AddItem($hListView_1, "15") _GUICtrlListView_AddSubItem($hListView_1, 14, "Eisenerz", 1) _GUICtrlListView_AddSubItem($hListView_1, 14, "test15", 2) Local $tab2 = GUICtrlCreateTabItem("Item IDs ") $hListView_2 = _GUICtrlListView_Create($Gui, "", 10, 30, 390, 270, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS, $LVS_SINGLESEL)) _GUICtrlListView_SetExtendedListViewStyle($hListView_2, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES)) _GUICtrlListView_SetBkColor($hListView_2, 0xC4C4C4) _GUICtrlListView_SetTextBkColor($hListView_2, 0xC4C4C4) _GUICtrlListView_AddColumn($hListView_2, "IDs", 50) _GUICtrlListView_AddColumn($hListView_2, "Itemart", 110) _GUICtrlListView_AddColumn($hListView_2, "Test", 110) _GUICtrlListView_AddItem($hListView_2, "1") _GUICtrlListView_AddSubItem($hListView_2, 0, "testA", 1) _GUICtrlListView_AddSubItem($hListView_2, 0, "test1", 2) _GUICtrlListView_AddItem($hListView_2, "2") _GUICtrlListView_AddSubItem($hListView_2, 1, "testB", 1) _GUICtrlListView_AddSubItem($hListView_2, 1, "test2", 2) _GUICtrlListView_AddItem($hListView_2, "3") _GUICtrlListView_AddSubItem($hListView_2, 2, "testC", 1) _GUICtrlListView_AddSubItem($hListView_2, 2, "test3", 2) ControlHide($Gui, "", $hListView_2) Local $tab3 = GUICtrlCreateTabItem("Commands") $hListView_3 = _GUICtrlListView_Create($Gui, "", 10, 30, 390, 270, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS, $LVS_SINGLESEL)) _GUICtrlListView_SetExtendedListViewStyle($hListView_3, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES)) _GUICtrlListView_SetBkColor($hListView_3, 0xC4C4C4) _GUICtrlListView_SetTextBkColor($hListView_3, 0xC4C4C4) _GUICtrlListView_AddColumn($hListView_3, "IDs", 50) _GUICtrlListView_AddColumn($hListView_3, "Itemart", 110) _GUICtrlListView_AddColumn($hListView_3, "Test", 110) _GUICtrlListView_AddItem($hListView_3, "1") _GUICtrlListView_AddSubItem($hListView_3, 0, "testX", 1) _GUICtrlListView_AddSubItem($hListView_3, 0, "test7", 2) _GUICtrlListView_AddItem($hListView_3, "2") _GUICtrlListView_AddSubItem($hListView_3, 1, "testY", 1) _GUICtrlListView_AddSubItem($hListView_3, 1, "test8", 2) _GUICtrlListView_AddItem($hListView_3, "3") _GUICtrlListView_AddSubItem($hListView_3, 2, "testZ", 1) _GUICtrlListView_AddSubItem($hListView_3, 2, "test9", 2) ControlHide($Gui, "", $hListView_3) Local $tab4 = GUICtrlCreateTabItem("Hilfe") GUICtrlCreateTabItem(""); end tabitem definition GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $tab Switch GUICtrlRead($tab) Case 0 ControlShow($Gui, "", $hListView_1) ControlHide($Gui, "", $hListView_2) ControlHide($Gui, "", $hListView_3) Case 1 ControlHide($Gui, "", $hListView_1) ControlShow($Gui, "", $hListView_2) ControlHide($Gui, "", $hListView_3) Case 2 ControlHide($Gui, "", $hListView_1) ControlHide($Gui, "", $hListView_2) ControlShow($Gui, "", $hListView_3) Case 3 ControlHide($Gui, "", $hListView_1) ControlHide($Gui, "", $hListView_2) ControlHide($Gui, "", $hListView_3) EndSwitch Case $cButton_Search $iRet = 1 $sSearchString = GUICtrlRead($cInput_Searchstring) If $sSearchString Then Switch GUICtrlRead($tab) Case 0 $iIndex = _GUICtrlListView_FindInText($hListView_1, $sSearchString) If $iIndex <> -1 Then _GUICtrlListView_SetItemState($hListView_1, $iIndex, $LVIS_SELECTED, $LVIS_SELECTED) _GUICtrlListView_EnsureVisible($hListView_1, $iIndex) $iRet = 0 EndIf Case 1 If $iIndex <> -1 Then $iIndex = _GUICtrlListView_FindInText($hListView_2, $sSearchString) _GUICtrlListView_SetItemState($hListView_2, $iIndex, $LVIS_SELECTED, $LVIS_SELECTED) _GUICtrlListView_EnsureVisible($hListView_2, $iIndex) $iRet = 0 EndIf Case 2 If $iIndex <> -1 Then $iIndex = _GUICtrlListView_FindInText($hListView_3, $sSearchString) _GUICtrlListView_SetItemState($hListView_3, $iIndex, $LVIS_SELECTED, $LVIS_SELECTED) _GUICtrlListView_EnsureVisible($hListView_3, $iIndex) $iRet = 0 EndIf EndSwitch Else $iRet = 2 EndIf Switch $iRet Case 0 Case 1 MsgBox(16, "Fehler", "Name wurde nicht gefunden.") Case 2 MsgBox(16, "Fehler", "Kein Suchwort eingegeben oder Textfeld leer.") EndSwitch EndSwitch WEndI have removed the sorting code - I have found that searching sortable ListViews is just too much trouble. If you really do want to have sortable ListViews than we might need to rethink the whole script and perhaps use an array to hold the data.Please ask if you have any questions. M23P.S. If this is what I think it is, you might want to change the BlockArt names - they rather give the game away. Edited April 11, 2011 by Melba23 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...
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