slayerz Posted June 26, 2008 Share Posted June 26, 2008 Hi everyone... I'd never use GUICtrlCreateListView before, so I need your help guys. How to display a list from text file? Let say I have file : item.ini [item1] date= 11:45 AM 27/6/2008 item = Kingston Data Traveller 2.0 Device status = Good #include <GUIConstantsEx.au3> #include <ListviewConstants.au3> Opt("GUIOnEventMode", 1) $GUI = GUICreate("Demo", 693, 230) GUISetBkColor(0xFFFBF0) GUISetOnEvent($GUI_EVENT_CLOSE, "GUIClose") $threatlist = GUICtrlCreateListView("Date/Time|Item Description|Condition", 9, 9, 675, 165, Default, BitOR($LVS_EX_GRIDLINES,$LVS_EX_FULLROWSELECT,$LVS_EX_CHECKBOXES)) GUICtrlSendMsg(-1, 0x101E, 0, 160) GUICtrlSendMsg(-1, 0x101E, 1, 310) GUICtrlSendMsg(-1, 0x101E, 2, 200) ; How to convert this part, to get the data from the file and display it in ListView? $item1 = GUICtrlCreateListViewItem("11:45 AM 27/6/2008|Kingston Data Traveller 2.0 Device|Good", $threatlist) $item2 = GUICtrlCreateListViewItem("1:45 PM 27/6/2008|External Hardisk|Good", $threatlist) $item3 = GUICtrlCreateListViewItem("3:45 PM 27/6/2008|MP4 Player|Poor", $threatlist) GUISetState(@SW_SHOW) ;Unfinished... $Button1 = GUICtrlCreateButton("Delete", 88, 180, 64, 48, 0) $Button2 = GUICtrlCreateButton("Clear", 416, 180, 64, 48, 0) While 1 Sleep(100) WEnd Func GUIClose() Exit EndFunc AUTOIT[sup] I'm lovin' it![/sup] Link to comment Share on other sites More sharing options...
DaRam Posted June 26, 2008 Share Posted June 26, 2008 Const $IniFile = "item.ini" Dim $I, $LVItmTxt For $I = 1 to 100 ; Increase if you have more items $LVItmTxt = IniRead($IniFile, "Item" & $I, "date") If @error Then ExitLoop If StringLen($Txt) < 1 Then ExitLoop ; No More $LVItmTxt &= "|" & IniRead($IniFile, "Item" & $I, "item", "") $LVItmTxt &= "|" & IniRead($IniFile, "Item" & $I, "status", "") GUICtrlCreateListViewItem($LVItmTxt, $threatlist) Next ;$I Link to comment Share on other sites More sharing options...
slayerz Posted June 27, 2008 Author Share Posted June 27, 2008 Const $IniFile = "item.ini" Dim $I, $LVItmTxt For $I = 1 to 100 ; Increase if you have more items $LVItmTxt = IniRead($IniFile, "Item" & $I, "date") If @error Then ExitLoop If StringLen($Txt) < 1 Then ExitLoop ; No More $LVItmTxt &= "|" & IniRead($IniFile, "Item" & $I, "item", "") $LVItmTxt &= "|" & IniRead($IniFile, "Item" & $I, "status", "") GUICtrlCreateListViewItem($LVItmTxt, $threatlist) Next ;$Ithanks for the reply...I'll try yours AUTOIT[sup] I'm lovin' it![/sup] Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted June 27, 2008 Share Posted June 27, 2008 If every device has it's own section then you could use IniReadSection() to shorten the code. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface 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