ComboBox ->Listview Filtern

  • Hallo,

    habe eine Frage habe folgende Listviewitems

    Host|IP|MAC|Datum

    pc1|192.168.01.13|00-13-E8-B8-57-E5|12.04.2010
    pc2|192.168.02.14|00-13-E8-B8-57-E6|13.04.2010
    pc3|192.168.03.15|00-13-E8-B8-57-E7|14.04.2010
    pc4|192.168.04.16|00-13-E8-B8-57-E8|15.04.2010
    pc5|192.168.05.17|00-13-E8-B8-57-E9|16.04.2010
    pc6|192.168.06.18|00-13-E8-B8-57-E10|17.04.2010
    pc7|192.168.07.19|00-13-E8-B8-57-E11|18.04.2010
    pc8|192.168.08.20|00-13-E8-B8-57-E12|19.04.2010
    pc9|192.168.10.21|00-13-E8-B8-57-E13|20.04.2010


    Ich möchte mit der combobox filtern und jeweils die segmente anzeigen lassen die in der Listview enthalten sind.

    01
    02
    03
    04
    05
    06
    07
    08
    09
    10

    autoit.de/wcf/attachment/9248/

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <GuiIPAddress.au3>
    #include <Array.au3>
    #include <GuiConstantsEx.au3>
    #include <GuiListView.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $Form1 = GUICreate("Get", 999, 628, 226, 231)
    ;$Input1 = GUICtrlCreateInput("P0XXXX", 24, 72, 73, 21)
    $Combo1 = GUICtrlCreateCombo("Segmente", 104, 72, 161, 25)
    ;$IPAddress1 = _GUICtrlIpAddress_Create($Form1, 104, 8, 162, 21)
    ;_GUICtrlIpAddress_Set($IPAddress1, "10.11.0.0")
    ;$IPAddress2 = _GUICtrlIpAddress_Create($Form1, 104, 40, 162, 21)
    ;_GUICtrlIpAddress_Set($IPAddress2, "10.11.255.255")
    $hListView1 = GUICtrlCreateListView("Host|IP|MAC|Last Seen", 24, 104, 930, 478)
    ;$Date1 = GUICtrlCreateDate("2010/04/27 20:50:50", 768, 8, 186, 21)
    ;$ListView2 = GUICtrlCreateListView("", 768, 32, 186, 54)
    $Button1 = GUICtrlCreateButton("Import", 24, 590, 155, 25, 0)
    ;$Button2 = GUICtrlCreateButton("Stop", 424, 48, 155, 25, 0)
    ;$Button3 = GUICtrlCreateButton("Makierte wecken", 414, 72, 93, 25, 0)
    ;$Button4 = GUICtrlCreateButton("Alle wecken", 504, 72, 75, 25, 0)
    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    _ditoimport()

    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    func _ditoimport()
    $sText= FileRead(FileOpenDialog("Datei wählen","","All (*.*)"))
    If @error Then $sText = ClipGet()

    [/autoit] [autoit][/autoit] [autoit]

    $aData = StringRegExp($sText,"(\S+)\s+(\S+)\s+(\S+)\s+(\S+\s+\S+)(?>.+)?",3)
    If @error Then Exit MsgBox(0,"","No Match!")
    _ArraySplit($aData,4)
    _ArrayDisplay($aData)
    ;For $i = 0 to Ubound($aData) - 1
    ;GUICtrlCreateListViewItem($aData[$i], $hListView1)
    ;Next
    _GUICtrlListView_AddArray($hListView1, $aData)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _ArraySplit(ByRef $aArray, $iCol)
    Local $iUB = Ceiling(UBound($aArray) / $iCol)
    If $iUB < 1 Then Return
    Local $aRet[$iUB][$iCol], $iC, $iUB2 = UBound($aArray)
    For $i = 0 To UBound($aArray) - 1 Step $iCol
    For $j = 0 To $iCol - 1
    If $i + $j >= $iUB2 Then ExitLoop
    $aRet[$iC][$j] = $aArray[$i + $j]
    Next
    $iC += 1

    Next
    ;GUICtrlCreateListViewItem($aArray[0], $hListView1)
    $aArray = $aRet
    EndFunc ;==>_ArraySplit

    [/autoit]

    Dateien

    lg SubZero ;)
    ==========================================================================

    "Der Computer ist die logische Weiterentwicklung des Menschen: Intelligenz ohne Moral."

  • Ich habe in der listview einträge:

    pc1|192.168.0.1|00-01-22-00-44-00|01.03.3010
    pc2|192.168.0.1|00-01-22-00-44-00|01.03.3010
    pc3|192.168.0.1|00-01-22-00-44-00|01.03.3010
    pc4|192.168.0.1|00-01-22-00-44-00|01.03.3010
    pc5|192.168.0.1|00-01-22-00-44-00|01.03.3010
    pc6|192.168.0.1|00-01-22-00-44-00|01.03.3010
    pc7|192.168.0.1|00-01-22-00-44-00|01.03.3010
    pc18|192.168.0.1|00-01-22-00-44-00|01.03.3010
    pc19|192.168.0.1|00-01-22-00-44-00|01.03.3010
    pc1|192.168.1.1|00-01-22-00-44-00|01.03.3010
    pc2|192.168.2.1|00-01-22-00-44-00|01.03.3010
    pc3|192.168.3.1|00-01-22-00-44-00|01.03.3010
    pc4|192.168.4.1|00-01-22-00-44-00|01.03.3010
    pc5|192.168.5.1|00-01-22-00-44-00|01.03.3010
    pc6|192.168.6.1|00-01-22-00-44-00|01.03.3010
    pc7|192.168.7.1|00-01-22-00-44-00|01.03.3010
    pc18|192.168.8.1|00-01-22-00-44-00|01.03.3010
    pc19|192.168.9.1|00-01-22-00-44-00|01.03.3010

    Ich möchte jetzt in der Combo Box nach dem feld IP filtern können:
    also alle Pc anzeigen lassen die in dem segment 192.168.0.* oder 192.168.1.* oder alle anzeigen lassen.
    also den filter deaktivieren wie mache ich das am besten?
    Alle PC können in der Range 192.168.0 - 192.168.255 sein

    lg SubZero ;)
    ==========================================================================

    "Der Computer ist die logische Weiterentwicklung des Menschen: Intelligenz ohne Moral."

  • Hier mal so wie ich es verstehe. Ich denk mal das meinst du.

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #Include <GuiListView.au3>
    #Include <Array.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global $aData[18] = ["pc1|192.168.0.1|00-01-22-00-44-00|01.03.3010", _
    "pc2|192.168.0.1|00-01-22-00-44-00|01.03.3010", _
    "pc3|192.168.0.1|00-01-22-00-44-00|01.03.3010", _
    "pc4|192.168.0.1|00-01-22-00-44-00|01.03.3010", _
    "pc5|192.168.0.1|00-01-22-00-44-00|01.03.3010", _
    "pc6|192.168.0.1|00-01-22-00-44-00|01.03.3010", _
    "pc7|192.168.0.1|00-01-22-00-44-00|01.03.3010", _
    "pc18|192.168.0.1|00-01-22-00-44-00|01.03.3010", _
    "pc19|192.168.0.1|00-01-22-00-44-00|01.03.3010", _
    "pc1|192.168.1.1|00-01-22-00-44-00|01.03.3010", _
    "pc2|192.168.2.1|00-01-22-00-44-00|01.03.3010", _
    "pc3|192.168.3.1|00-01-22-00-44-00|01.03.3010", _
    "pc4|192.168.4.1|00-01-22-00-44-00|01.03.3010", _
    "pc5|192.168.5.1|00-01-22-00-44-00|01.03.3010", _
    "pc6|192.168.6.1|00-01-22-00-44-00|01.03.3010", _
    "pc7|192.168.7.1|00-01-22-00-44-00|01.03.3010", _
    "pc18|192.168.8.1|00-01-22-00-44-00|01.03.3010", _
    "pc19|192.168.9.1|00-01-22-00-44-00|01.03.3010"]

    [/autoit] [autoit][/autoit] [autoit]

    Global $aDataSelect = $aData

    [/autoit] [autoit][/autoit] [autoit]

    $hGui = GUICreate("Gui", 350, 260)
    GUICtrlCreateLabel("Filter IP:", 10, 20, 40, 17)
    $hCombo = GUICtrlCreateCombo("", 55, 17, 50, 20)
    GUICtrlSetData(-1, "All")
    For $i = 0 To 255
    GUICtrlSetData(-1, $i)
    Next
    $hListview = GUICtrlCreateListView("Host|IP|MAC|Last Seen", 10, 50, 340, 200)
    For $i = 0 To UBound($aData) - 1
    GUICtrlCreateListViewItem($aData[$i], $hListview)
    Next
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    Exit
    Case $hCombo
    _GUICtrlListView_DeleteAllItems($hListview)
    Switch GUICtrlRead($hCombo)
    Case "All"
    $aDataSelect = $aData
    Case 0 To 255
    ReDim $aDataSelect[1]
    $aDataSelect[0] = "None"
    For $i = 0 To UBound($aData) - 1
    $aSplit = StringSplit($aData[$i], "|")
    $aSplit = StringSplit($aSplit[2], ".")
    If GUICtrlRead($hCombo) = $aSplit[3] Then
    ConsoleWrite(@CRLF & $aData[$i])
    ReDim $aDataSelect[UBound($aDataSelect) + 1]
    $aDataSelect[UBound($aDataSelect) - 1] = $aData[$i]
    EndIf
    Next
    If UBound($aDataSelect) <> 1 Then _ArrayDelete($aDataSelect, 0)
    EndSwitch
    For $i = 0 To UBound($aDataSelect) - 1
    GUICtrlCreateListViewItem($aDataSelect[$i], $hListview)
    Next
    EndSwitch
    WEnd

    [/autoit]