Sign in to follow this  
Followers 0
TanerJames

listview two lines

8 posts in this topic

hi,

How to add two lines in a single row in listview?

example:

----------------------------

data1

data1bbbb

----------------------------

i try @CRLF or chr(13) not support

result data1data1bbbb

thanks

Share this post


Link to post
Share on other sites



Well, it's listview so next line is another item. I'm affraid this is not possible.


When the words fail... music speaks

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

What is the alternative? Because I have a need for this. It doesn't have to be a ListView. I just want a control that will list multiple rows of data and to display their data in a single Element with multiple lines.

Take a look a my Trello page Their web UI has a container, and inside that container they have single data elements stacked vertically, each displaying multiple pieces of info, various images etc. 

Edited by JakeKenmode

Share this post


Link to post
Share on other sites

You can create a simple list, so you just have to use GUICtrlSetData to set the data with "|" as separator for each element :

GUICreate("GUI")

GUICtrlCreateList("", 10, 10, 380, 380)
GUICtrlSetData(-1, "row1|row2|row3")

GUISetState()

While GUIGetMsg() <> -3
    Sleep(10)
WEnd

Share this post


Link to post
Share on other sites

Thats a single control creating multiple single lines with a single SetData call.

Thats no different than a for each calling SetData 3 times each time. 

Im talking about a control that contains a list of objects and each object has multiple params to display, so when clicked it selects the entire object that holds all of the smaller pieces of data.  

I need this because I am dragging and dropping the entire object and all of it's data onto another control where it will read all that data and create another object for the control it is dropped into.

Picture dragging a triangle with information in it - into a new control, it reads the data, creates a square and populates it with that data. Same data - different object.

Share this post


Link to post
Share on other sites

The only control that I know of that does that is a Edit control (I'm not versed in all the controls so...).  You could drag whatever you wanted and just reparse it everytime.  Its either that or create a custom control of your own

Share this post


Link to post
Share on other sites

The only control that I know of that does that is a Edit control (I'm not versed in all the controls so...).  You could drag whatever you wanted and just reparse it everytime.  Its either that or create a custom control of your own

Yup, that is where I was going :) Just feeling out the possibility of doing it with maybe some existing control or UDF control, no luck yet. 

Looks like its custom control to me as well at this point. I just resurrected this post from 2012 to see if there was anyone out there using something like this.

Share this post


Link to post
Share on other sites

JakeKenmode,

Here is a short script that might give you some pointers on how to create something along the lines you are looking for: :)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#include <GUIScrollbars_Size.au3>

Global $iDepth = 100                                        ; Depth of each element
$iNext_Y = 0                                                ; Y coord of next element
Global $aColour[3] = [0xFFCCCC, 0xCCFFCC, 0xCCCCFF]     ; Colours to differentiate elements
$iNext_Colour = 0
$iCount = 1                                                 ; Index for next element

Global $aScrollParams[4] = [0, 0, 0, 0]                 ; Placeholder for scroll size data

; Create GUI
$hGUI = GUICreate("Test", 500, 220)
; Create menu
$mFile = GUICtrlCreateMenu("File")
$mFile_Exit = GUICtrlCreateMenuItem("Exit", $mFile)
$mEdit = GUICtrlCreateMenu("Edit")
$mEdit_Add = GUICtrlCreateMenuItem("Add", $mEdit)

GUISetState()

; Determine GUI client depth
$iClient_Depth = (WinGetClientSize($hGUI))[1]

; Register scroll handler
GUIRegisterMsg($WM_VSCROLL, "_Scrollbars_WM_VSCROLL")

; Create and hide scrollbars
_GUIScrollBars_Init($hGUI)
_GUIScrollBars_ShowScrollBar($hGUI, $SB_HORZ, False)
_GUIScrollBars_ShowScrollBar($hGUI, $SB_VERT, False)

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $mFile_Exit
            Exit
        Case $GUI_EVENT_RESTORE
            _GUIScrollbars_Restore($hGUI, True, False)
        Case $mEdit_Add
            ; Scroll to start
            _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, 0)
            ; Add next edit
            $cEdit = GUICtrlCreateEdit($iCount, 0, $iNext_Y, 480, $iDepth)
            GUICtrlSetBkColor($cEdit, $aColour[$iNext_Colour])
            ; Increase for next addition
            $iCount += 1
            $iNext_Y += 100
            $iNext_Colour = Mod($iNext_Colour + 1, 3)
            ; If now over GUI client depth
            If $iNext_Y > $iClient_Depth Then
                ; Show vert scrollbar
                _GUIScrollBars_ShowScrollBar($hGUI, $SB_VERT, True)
                ; Determine and set required scroll parameters
                $aScrollParams = _GUIScrollbars_Size(0, $iNext_Y, 0, $iClient_Depth)
                _GUIScrollBars_SetScrollInfoPage($hGUI, $SB_VERT, $aScrollParams[2])
                _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_VERT, $aScrollParams[3])
            EndIf
            ; Scroll to show new element
            _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, $aScrollParams[3])
    EndSwitch

WEnd

Func _Scrollbars_WM_VSCROLL($hWnd, $Msg, $wParam, $lParam)

    #forceref $Msg, $wParam, $lParam
    Local $nScrollCode = BitAND($wParam, 0x0000FFFF)
    Local $iIndex = -1, $yChar, $yPos
    Local $Min, $Max, $Page, $Pos, $TrackPos

    For $x = 0 To UBound($__g_aSB_WindowInfo) - 1
        If $__g_aSB_WindowInfo[$x][0] = $hWnd Then
            $iIndex = $x
            $yChar = $__g_aSB_WindowInfo[$iIndex][3]
            ExitLoop
        EndIf
    Next
    If $iIndex = -1 Then Return 0

    Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT)
    $Min = DllStructGetData($tSCROLLINFO, "nMin")
    $Max = DllStructGetData($tSCROLLINFO, "nMax")
    $Page = DllStructGetData($tSCROLLINFO, "nPage")
    $yPos = DllStructGetData($tSCROLLINFO, "nPos")
    $Pos = $yPos
    $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")

    Switch $nScrollCode
        Case $SB_TOP
            DllStructSetData($tSCROLLINFO, "nPos", $Min)
        Case $SB_BOTTOM
            DllStructSetData($tSCROLLINFO, "nPos", $Max)
        Case $SB_LINEUP
            DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1)
        Case $SB_LINEDOWN
            DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1)
        Case $SB_PAGEUP
            DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page)
        Case $SB_PAGEDOWN
            DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page)
        Case $SB_THUMBTRACK
            DllStructSetData($tSCROLLINFO, "nPos", $TrackPos)
    EndSwitch

    DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)
    _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)

    $Pos = DllStructGetData($tSCROLLINFO, "nPos")
    If ($Pos <> $yPos) Then
        _GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos))
        $yPos = $Pos
    EndIf

    Return $GUI_RUNDEFMSG

EndFunc   ;==>_Scrollbars_WM_VSCROLL
You will need my GUIScrollbars_Size UDF - look in my sig for the link. Please ask if you have any questions. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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