|
You last visited: Today at 01:33
Advertisement
Liste anzeigen in tabelle und alphabetisch sortieren
Discussion on Liste anzeigen in tabelle und alphabetisch sortieren within the AutoIt forum part of the Coders Den category.
02/24/2014, 17:32
|
#16
|
elite*gold: 280
Join Date: May 2007
Posts: 2,818
Received Thanks: 3,483
|
Quote:
Originally Posted by Shadow992
Und dann liest du die Datei ein und machst zuerst ein StringSplit nach @CRLF
und danach nach "|" und dann hast du deine Einträge auch auf mehrere Arrays verteilt.
|
noch einfacher wäre es wohl, auf das @crlf zu verzichten und alles direkt in einem schritt einzulesen.
beim einarbeiten ins gui dann einfach unnötige glieder überspringen
beispiel:
Code:
#include <GuiListView.au3>
; global variables
Global Const $stateIdle = "Idle", $stateAddEntry = "Adding Entrys"
Global $array[65532][4] ; [controlID][name,beschreibung,typ,nummer]
; main gui
$guiMain = GUICreate('GUI', 400, 400, Default, Default, 0x10C80000)
$listView = GUICtrlCreateListView("Name|Beschreibung|Typ|Nummer", 0, 0, 400, 360)
_GUICtrlListView_RegisterSortCallBack($listView)
$btnAdd = GUICtrlCreateButton('Add Entry', 0, 360, 200, 20)
$btnDel = GUICtrlCreateButton('Delete Entry', 200, 360, 200, 20)
$lblStatus = GUICtrlCreateLabel($stateIdle, 0, 380, 400, 20, 0x201)
; add info gui
$guiAddEntry = GUICreate('Add Entry', 200, 122, -1, -1, 0xC80000, -1, $guiMain)
GUICtrlCreateGroup('Name', 2, 0, 98, 45)
$inptName = GUICtrlCreateInput('', 7, 20, 88, 20)
GUICtrlCreateGroup('Beschreibung', 100, 0, 98, 45)
$inptBeschreibung = GUICtrlCreateInput('', 105, 20, 88, 20)
GUICtrlCreateGroup('Typ', 2, 50, 98, 45)
$inptTyp = GUICtrlCreateInput('', 7, 70, 88, 20)
GUICtrlCreateGroup('Nummer', 100, 50, 98, 45)
$inptNummer = GUICtrlCreateInput('', 105, 70, 88, 20)
$btnAddAdd = GUICtrlCreateButton('Add', 0, 98, 100, 20)
$btnCancel = GUICtrlCreateButton('Cancel', 100, 98, 100, 20)
LoadAll()
While True
$msg = GUIGetMsg(1)
Switch $msg[0]
Case -3, $btnCancel
If $msg[1] = $guiMain Then
SaveAll()
Exit
EndIf
GUISetState(@SW_HIDE, $msg[1])
Case $listView
_GUICtrlListView_SortItems($listView, GUICtrlGetState($listView))
Case $btnAdd
GUISetState(@SW_SHOW, $guiAddEntry)
Case $btnDel
DelEntry(GUICtrlRead($listView))
Case $btnAddAdd
If GUICtrlRead($inptName) And GUICtrlRead($inptBeschreibung) And GUICtrlRead($inptTyp) And GUICtrlRead($inptNummer) Then
SetState($stateAddEntry)
AddEntry(GUICtrlRead($inptName), GUICtrlRead($inptBeschreibung), GUICtrlRead($inptTyp), GUICtrlRead($inptNummer))
GUISetState(@SW_HIDE, $msg[1])
SetState($stateIdle)
Else
MsgBox(0, "Info", "Set all empty fields first!")
EndIf
EndSwitch
WEnd
Func AddEntry($name, $beschreibung, $typ, $nummer)
Local $id = GUICtrlCreateListViewItem($name&'|'&$beschreibung&'|'&$typ&'|'&$nummer, $listView)
$array[$id][0] = $name
$array[$id][1] = $beschreibung
$array[$id][2] = $typ
$array[$id][3] = $nummer
EndFunc
Func DelEntry($id)
If $id=0 Then
MsgBox(0, "Info", "Select an Entry First")
Return 0
EndIf
For $i=0 To 3
$array[$id][$i]=''
Next
GUICtrlDelete($id)
EndFunc
Func SetState($string)
GUICtrlSetData($lblStatus, $string)
EndFunc
Func LoadAll()
SetState($stateAddEntry)
Local $content = StringSplit(FileRead("content.txt"),'|')
If $content[0]=1 Then Return False
For $i=1 To $content[0] Step 4
AddEntry($content[$i], $content[$i+1], $content[$i+2], $content[$i+3])
Next
SetState($stateIdle)
EndFunc
Func SaveAll()
Local $content
For $i=0 To 65531
If $array[$i][0] Then $content&=$array[$i][0]&'|'&$array[$i][1]&'|'&$array[$i][2]&'|'&$array[$i][3]&'|'
Next
$hwnd = FileOpen("content.txt", 2)
FileWrite($hwnd, StringTrimRight($content,1))
FileClose($hwnd)
EndFunc
|
|
|
|
|
Similar Threads
|
[HTML] Tabelle sortieren
04/22/2013 - Web Development - 1 Replies
Hi, ich möchte, dass meine Tabelle sortiert werden kann.
Ich habe dieses Beispiel verwendet: Sortierbare Tabelle , aber es funktioniert nicht :(
Hier meine Tabelle:
<html><head>
<title>Proxylist</title>
</head><body>
<p align="left">Proxylist last updated 2013-04-22 11:12 +0000 UTC</p><hr>
<div class="JSTableSort">
|
Bot zum sortieren/einordnen
10/11/2012 - AutoIt - 4 Replies
Hi, ich mal wieder..... Ich brauch ma wieder hilfe ......und zwar wollt ich ein kleines Programm für die schule machen....
http://www7.pic-upload.de/thumb/11.10.12/4gcsnnbt 3zss.jpg
So ALso zuerst trägt man natürlich alles ein ......dann wenn ich ok drücke soll er es auf drei textdocumente aufteilen
das erste .... nach projekten geoordnet Projekt 1 -Projekt 41 und wenn ich zum beispiel als name Peter eingegeben habe und als erstwahl projekt 1 hab soll da stehen:
Erstwahlen
|
Liste der Anhänge anzeigen (Anzahl: 1) [B] Steam acc Black Ops; Mw2 etc. [S] Wr acc
07/17/2011 - WarRock Trading - 0 Replies
Ich biete steam acc mit Folgenden Spielen :
|
Listitems non-alphabetisch anordnen
05/28/2010 - AutoIt - 2 Replies
GUICtrlSetData($list, $new & $old)
Wenn ich es nach diesem Prinzip versuche, werden die Einträge immer nach dem Alphabet geordnet.
Wie kann ich das ändern?
|
All times are GMT +1. The time now is 01:33.
|
|