Sign in to follow this  
Followers 0
Affe

Listviews and Carriage Returns/Line Feeds

7 posts in this topic

I've been developing a program that uses a listview to display data. Some of the data contains carriage returns and line feeds "@CRLF".

Everything displays perfectly on my x64 machine under both Windows 7 and Vista.

However, I seem to be having some issues on my x32 WinXP machine. Carriage returns and line feeds aren't shown properly, instead displaying "" (<- supposed to be a box).

This doesn't produce a very aesthetic look, and I've been hoping to find a solution - any suggestions?


[center][/center]

Share this post


Link to post
Share on other sites



Try StringStripCR() before adding to ListView.

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

Thanks for the fast reply, however, I'm wishing to keep the multi-line output.

I tried stripping the CR and leaving the line feeds as you suggested. This simply changes it from showing 2 boxes between each line to one box, and still no multiple lines.

Thanks again


[center][/center]

Share this post


Link to post
Share on other sites

Read your file to an array with StringSplit($file, @lf).

Afterwards put each line from array to Listview with StringStripCR($array[$i]).

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

Ah I'm sorry, I must have not been clear on this.

I'm able to fill out my Listview with all of the rows and columns just fine.

It's only a display issue, where one of the sub items on an index contains text that have line feeds in them.

Here's the section of code where I'm populating the Listview. The variable $itemname is the element that contains the @CRLF:

ProgressOn("Antfamous.net Auctioneer", "Initializing Selection")
    Sleep(250)
    _GUICtrlListView_BeginUpdate($hListView)
    For $x = 0 To UBound($Browse_Array) - 1
        ProgressSet((($x + 1) / $ttl) * 100, "Item " & ($x + 1) & " of " & $ttl, "Compiling Selection")

        $imgloc = $images_directory & $Browse_Array[$x][8] & ".bmp"

        If FileExists($imgloc) Then
            _GUIImageList_AddBitmap($hImage, $imgloc)
        Else
            _GUIImageList_AddBitmap($hImage, $images_directory & "Unknown.bmp")
        EndIf

        $itemname = ""
        $tmp = StringSplit($Browse_Array[$x][1], "&", 1)
        For $i = 1 To $tmp[0]
            $tmp2 = StringSplit($tmp[$i], "^", 1)
            $itemname &= $tmp2[1] & @CRLF
        Next

        $desc = $Browse_Array[$x][14]

        $iParam = $Browse_Array[$x][0]

        $Items_Array[$x][0] = GUICtrlCreateListViewItem("", $hListView)
        _GUICtrlListView_AddItem($hListView, "", $x, $iParam)
        _GUICtrlListView_AddSubItem($hListView, $x, $itemname, 1)
        _GUICtrlListView_AddSubItem($hListView, $x, $Browse_Array[$x][22], 2)

        $auc_tsa = String($Browse_Array[$x][2])
        $auc_ts = StringLeft($auc_tsa, 4) & "/"
        $auc_tsa = StringTrimLeft($auc_tsa, 4)
        $auc_ts &= StringLeft($auc_tsa, 2) & "/"
        $auc_tsa = StringTrimLeft($auc_tsa, 2)
        $auc_ts &= StringLeft($auc_tsa, 2) & " "
        $auc_tsa = StringTrimLeft($auc_tsa, 2)
        $auc_ts &= StringLeft($auc_tsa, 2) & ":"
        $auc_tsa = StringTrimLeft($auc_tsa, 2)
        $auc_ts &= StringLeft($auc_tsa, 2) & ":"
        $auc_tsa = StringTrimLeft($auc_tsa, 2)
        $auc_ts &= StringLeft($auc_tsa, 2)

        $time = _DateDiff("h", $auc_ts, $cur_ts)
        $timeleft = Int($Browse_Array[$x][3] - $time)
        _GUICtrlListView_AddSubItem($hListView, $x, $timeleft, 3)

        _GUICtrlListView_AddSubItem($hListView, $x, $Browse_Array[$x][6], 4)

        $buy = $Browse_Array[$x][7]
        If $buy = "0" Then $buy = "None"
        _GUICtrlListView_AddSubItem($hListView, $x, $buy, 5)

        $Items_Array[$x][1] = $Browse_Array[$x][0]

        $Items_Array[$x][2] = $Browse_Array[$x][1] & "&" & $desc

        $tmparray = StringSplit($Items_Array[$x][2], "&", 1)
            Dim $des_array[$tmparray[0]][2]
            For $k = 1 to $tmparray[0]
                $tmp = StringSplit($tmparray[$k], "^", 1)
                $des_array[$k - 1][0] = $tmp[1]
                $des_array[$k - 1][1] = "0x" & $tmp[2]
            Next

        $Items_Array[$x][2] = $des_array


    Next
    ProgressSet(100, "Finalizing Selection...", "Compiling Selection Complete")
    Sleep(250)
    ProgressOff()
    _GUICtrlListView_SetImageList($hListView, $hImage, 1)
    _GUICtrlListView_EndUpdate($hListView)

[center][/center]

Share this post


Link to post
Share on other sites

Didn't seem to help :unsure: I think I'll just have to StringReplace the @CRLF with spaces if StringInStr(@OSVersion, "WIN_XP")

Thanks for trying though :>


[center][/center]

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  
Followers 0