taylansan Posted June 29, 2011 Share Posted June 29, 2011 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 ;==>ExampleThe 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. TY. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 29, 2011 Moderators Share Posted June 29, 2011 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: expandcollapse popup#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 ;==>ExampleNow 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. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
taylansan Posted June 29, 2011 Author Share Posted June 29, 2011 Thank you very much for the post. But the fields are in horizontal position. I need them in vertical TY. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 29, 2011 Moderators Share Posted June 29, 2011 altamir,the right side is the desired oneAnd that is what I gave you. I need them in verticalDo 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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