Sign in to follow this  
Followers 0
taylansan

GUICtrlCreateListView convert to vertical style

4 posts in this topic

Hello,

I need some help about a GUI function "GUICtrlCreateListView". Here the fields are listed in horizontal, but i need them on vertical style. I have searched on forums also, tried to apply a few trics but still wasn't able to create as i desired.

Here is the little code (generally same as with the function help page itself):

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

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $listview, $item1, $item2, $msg, $listnumbers
    
    GUICreate("listview items", 220, 250, 500, 200, -1, $WS_EX_ACCEPTFILES)
    GUISetBkColor(0x00E0FFFF)  ; will change background color

    $listview = GUICtrlCreateListView("col1|col2|col3", 10, 40, 200, 150);,$LVS_SORTDESCENDING)
    $item1 = GUICtrlCreateListViewItem("A|B|C", $listview)
    $item2 = GUICtrlCreateListViewItem("||D", $listview)
    GUISetState()

    Do
        $msg = GUIGetMsg()
        
        Select
            Case $msg = $listview
                MsgBox(0, GUICtrlRead($listview), "clicked=" & GUICtrlGetState($listview), 2)
        EndSelect
    Until $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

The left side is the current view, and the right side is the desired one.

  • Need an upper label containing Value1 and Value2
  • $item1 and $item2 shouldn't be changed (well, change if you have an idea - i would appriciate that)
  • Once the subscriber clicks on "col1" a msg box should appear with the title "col1". Because, as you can see on the left side, it writes "0"

Any comments or codes or ideas are welcome.

Thanks in advance.

post-23255-0-00215600-1309352614_thumb.j


TY.

Share this post


Link to post
Share on other sites



altamir,

You cannot add the $item1/$item2 variables directly to a ListView as columns - ListViews only accept rows. ;)

But you can create new values to pass as rows to the ListView by extracting the data from those variables like this: ;)

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

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $listview, $item1, $item2, $msg, $listnumbers

    ; Declare the original variables
    Local $sTitles = "No|Field|Value 1|Value2"
    Local $sItem0 = "col1|col2|col3"
    Local $sItem1 = "A|B|C"
    Local $sItem2 = "||D"

    ; Split the original variables
    Local $aSplit0 = StringSplit($sItem0, "|")
    Local $aSplit1 = StringSplit($sItem1, "|")
    Local $aSplit2 = StringSplit($sItem2, "|")

    GUICreate("listview items", 220, 250, 500, 200, -1, $WS_EX_ACCEPTFILES)
    GUISetBkColor(0x00E0FFFF)  ; will change background color

    $listview = GUICtrlCreateListView($sTitles, 10, 40, 200, 150);,$LVS_SORTDESCENDING)
    ; Get anchor ControlID for listview items
    Local $hCID = GUICtrlCreateDummy()
    For $i = 1 To $aSplit0[0]
        ; Create the lines required
        Local $sLine = $i & "|" & $aSplit0[$i] & "|" & $aSplit1[$i] & "|" & $aSplit2[$i]
        GUICtrlCreateListViewItem($sLine, $listview)
    Next

    GUISetState()

    Do
        $msg = GUIGetMsg()

        Select
            Case $msg = $GUI_EVENT_PRIMARYDOWN
                ; Is the ListView focused
                If _WinAPI_GetFocus() = GUICtrlGetHandle($listView) Then
                    ; Then calculate line number
                    MsgBox(0, GUICtrlRead($listview), "clicked = " & GUICtrlRead($listview) - $hCID, 2)
                EndIf
        EndSelect
    Until $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Now you have the elements in the correct format and the lines show as you wish. :)

The test for the line clicked is pretty basic. I hope it suffices - if not let me know and we can do complicated thing with GUIRegisterMsg. :D

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

Thank you very much for the post.

But the fields are in horizontal position. I need them in vertical :)


TY.

Share this post


Link to post
Share on other sites

altamir,

the right side is the desired one

And that is what I gave you. ;)

I need them in vertical

Do you want the text to be vertical? :)

If so I have no idea how to do it. ;)

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