Jump to content
Sign in to follow this  
MyEarth

N00b question, separate text in column

Recommended Posts

MyEarth

Title say all :D

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 by MyEarth

Share this post


Link to post
Share on other sites
water

The example in the help file tells you how to do ;)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
mikell

#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

?

Share this post


Link to post
Share on other sites
MyEarth

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 by MyEarth

Share this post


Link to post
Share on other sites
water

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 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
MyEarth

Thanks water, but i need to call it every time i'll fill the list?

Edited by MyEarth

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×