MyEarth Posted February 3, 2014 Share Posted February 3, 2014 (edited) Title say all I'm fill a listview usign a txt, how to separate the value in different column? Now as only one column with value: aaa - bbb - ccc I want three colum: aaa column 1 bbb comun 2 ccc column3 I need the first line with RESERVED only on the first column with nothing on others My code until now: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> $Myfile = "aaa - bbb - ccc" & @LF & "111 - 222 - 333" $Form = GUICreate("Form1", 378, 282, 170, 147) $ListView = GUICtrlCreateListView("NOVALUE", 8, 8, 353, 233, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_CHECKBOXES)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 200) $hListView = GUICtrlGetHandle($ListView) $Button = GUICtrlCreateButton("Fill", 8, 248, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button _Fill() EndSwitch WEnd Func _Fill() GUICtrlCreateListViewItem("RESERVED", $ListView) $aArray = StringSplit($Myfile, @LF) For $i = 1 To $aArray[0] GUICtrlCreateListViewItem($aArray[$i], $ListView) Next EndFunc ;==>_Fill Many thanks EDIT: Oh, and how to set the column size depending on the text, i have forget about that Edited February 3, 2014 by MyEarth Link to comment Share on other sites More sharing options...
water Posted February 3, 2014 Share Posted February 3, 2014 The example in the help file tells you how to do My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Solution mikell Posted February 3, 2014 Solution Share Posted February 3, 2014 #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> $Myfile = "aaa - bbb - ccc" & @LF & "111 - 222 - 333" $Form = GUICreate("Form1", 378, 282, 170, 147) $ListView = GUICtrlCreateListView("col 1|col 2|col 3", 8, 8, 353, 233, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_CHECKBOXES)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 200) $hListView = GUICtrlGetHandle($ListView) $Button = GUICtrlCreateButton("Fill", 8, 248, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button _Fill() EndSwitch WEnd Func _Fill() GUICtrlCreateListViewItem("RESERVED", $ListView) $aArray = StringSplit($Myfile, @LF) For $i = 1 To $aArray[0] $aArray[$i] = StringReplace($aArray[$i], " - ", "|") GUICtrlCreateListViewItem($aArray[$i], $ListView) Next EndFunc ;==>_Fill ? Link to comment Share on other sites More sharing options...
MyEarth Posted February 3, 2014 Author Share Posted February 3, 2014 (edited) I want to start with only one column and then add the others, is possible? And how to set the size of the column based on the text? Thanks to both EDIT: I have found the needed function: _GUICtrlListView_InsertColumn _GUICtrlListView_SetColumnWidth ( $LVSCW_AUTOSIZE ) Thanks guys and sorry Edited February 3, 2014 by MyEarth Link to comment Share on other sites More sharing options...
water Posted February 3, 2014 Share Posted February 3, 2014 To set the column width to fit the data use GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, $i, $LVSCW_AUTOSIZE) $i is the zero based column number. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
MyEarth Posted February 3, 2014 Author Share Posted February 3, 2014 (edited) Thanks water, but i need to call it every time i'll fill the list? Edited February 3, 2014 by MyEarth 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