JAFN Posted April 27, 2011 Share Posted April 27, 2011 Neither directly defining the column right justified nor assigning it right justified later, nor designating the data as numbers nor any combination of the three achieves right justification in the listview. {code] $Column1 = _GUICtrlListView_SetColumn($ListViewHandle, 1, "Price", 80, 1) $Column2 = _GUICtrlListView_SetColumn($ListViewHandle, 2, "Quantity", 80, 1) _GUICtrlListView_SetColumn($ListViewHandle, 3, "Genre", 80, 0) _GUICtrlListView_AddArray($ListViewHandle, $Data) _GUICtrlListView_JustifyColumn($Column1, 1, 1) [\code] What am I doing wrong? [size="2"]The second mouse gets the cheese[/size] Link to comment Share on other sites More sharing options...
BrewManNH Posted April 27, 2011 Share Posted April 27, 2011 Are you using the Control ID of the listview control or the handle? Whichever you're using try using the _JustifyColumn with the opposite and see if that has any effect. Sometimes things work differently when using a ControlID (the variable holds a control id if you used GuiCtrlCreateListview, it holds a handle if you used _GUICtrlListview_Create). If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 27, 2011 Moderators Share Posted April 27, 2011 JAFN,Check the syntax for _GUICtrlListView_JustifyColumn and the return value from _GUICtrlListView_SetColumn in the Help file. I think you should have:_GUICtrlListView_JustifyColumn($ListViewHandle, 1, 1)$Column1 and $Column2 are True/False and so not very likely to act as ID parameters. 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...
JAFN Posted April 27, 2011 Author Share Posted April 27, 2011 JAFN, Check the syntax for _GUICtrlListView_JustifyColumn and the return value from _GUICtrlListView_SetColumn in the Help file. I think you should have: _GUICtrlListView_JustifyColumn($ListViewHandle, 1, 1) $Column1 and $Column2 are True/False and so not very likely to act as ID parameters. M23 what you are suggesting is I think what I originally had trouble with. So I reloaded the backup. $ListViewHandle = GUICtrlCreateListView("Title|Price|Test|Genre", $SidesSep, $TopBottomSep, 450, $Height - ($TopBottomSep * 2), $LVS_SINGLESEL) $hListView = GUICtrlGetHandle($ListViewHandle) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_TRACKSELECT)) _GUICtrlListView_SetColumn($ListViewHandle, 0, "Title", 200, 0) _GUICtrlListView_SetColumn($ListViewHandle , 1, "Price", 80, 1) _GUICtrlListView_SetColumn($ListViewHandle , 2, "Quantity", 80, 1) _GUICtrlListView_SetColumn($ListViewHandle , 3, "Genre", 80, 0) _GUICtrlListView_AddArray($ListViewHandle, $Data) _GUICtrlListView_JustifyColumn($hListView, 1, 1) All for columns are left justified and I don't understand why. [size="2"]The second mouse gets the cheese[/size] Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 28, 2011 Share Posted April 28, 2011 (edited) This works fine for me: #include <GuiConstantsEx.au3> #include <GuiListView.au3> Global $Data[5][4] For $r = 0 To UBound($Data) - 1 For $c = 0 To UBound($Data, 2) - 1 $Data[$r][$c] = $r & "-" & $c Next Next Global $iJust = 0 Global $hGUI = GUICreate("Test", 470, 300) Global $idLV = GUICtrlCreateListView("Title|Price|Test|Genre", 10, 10, 450, 230, $LVS_SINGLESEL) Global $idButton = GUICtrlCreateButton("TEST", 185, 250, 100, 30) _GUICtrlListView_SetExtendedListViewStyle($idLV, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_TRACKSELECT)) _GUICtrlListView_SetColumn($idLV, 0, "Title", 100, 0) _GUICtrlListView_SetColumn($idLV, 1, "Price", 100, 0) _GUICtrlListView_SetColumn($idLV, 2, "Quantity", 100, 0) _GUICtrlListView_SetColumn($idLV, 3, "Genre", 100, 0) _GUICtrlListView_AddArray($idLV, $Data) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $idButton $iJust += 1 If $iJust > 2 Then $iJust = 0 _GUICtrlListView_JustifyColumn($idLV, 1, $iJust) _GUICtrlListView_RedrawItems($idLV, 0, _GUICtrlListView_GetItemCount($idLV) - 1) EndSwitch WEnd If you comment out the _GuiCtrlListView_RedrawItems(), then only the label changes. P.S. The results don't change if you use the listview handle instead of the ControlID because the UDF functions check the first parameter and retrieve the handle if required. Edited April 28, 2011 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
JAFN Posted April 28, 2011 Author Share Posted April 28, 2011 This works fine for me: #include <GuiConstantsEx.au3> #include <GuiListView.au3> Global $Data[5][4] For $r = 0 To UBound($Data) - 1 For $c = 0 To UBound($Data, 2) - 1 $Data[$r][$c] = $r & "-" & $c Next Next Global $iJust = 0 Global $hGUI = GUICreate("Test", 470, 300) Global $idLV = GUICtrlCreateListView("Title|Price|Test|Genre", 10, 10, 450, 230, $LVS_SINGLESEL) Global $idButton = GUICtrlCreateButton("TEST", 185, 250, 100, 30) _GUICtrlListView_SetExtendedListViewStyle($idLV, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_TRACKSELECT)) _GUICtrlListView_SetColumn($idLV, 0, "Title", 100, 0) _GUICtrlListView_SetColumn($idLV, 1, "Price", 100, 0) _GUICtrlListView_SetColumn($idLV, 2, "Quantity", 100, 0) _GUICtrlListView_SetColumn($idLV, 3, "Genre", 100, 0) _GUICtrlListView_AddArray($idLV, $Data) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $idButton $iJust += 1 If $iJust > 2 Then $iJust = 0 _GUICtrlListView_JustifyColumn($idLV, 1, $iJust) _GUICtrlListView_RedrawItems($idLV, 0, _GUICtrlListView_GetItemCount($idLV) - 1) EndSwitch WEnd If you comment out the _GuiCtrlListView_RedrawItems(), then only the label changes. P.S. The results don't change if you use the listview handle instead of the ControlID because the UDF functions check the first parameter and retrieve the handle if required. I must be screwing things up further down the road as things is also all left justified and not editing correctly on 1 and 2. Thanks for your time. [size="2"]The second mouse gets the cheese[/size] Link to comment Share on other sites More sharing options...
JAFN Posted April 28, 2011 Author Share Posted April 28, 2011 I had indeed fouled things up further down the line. Sorry to waste everyones time. One other thing. The first column of my listview is fairly long and some of the items rather short. So I was wondering if anyone had any ideas on alternating the background color of the header? My current non-alternating code is Func RefreshListView() GUICtrlSetState($Refresh, $GUI_DISABLE) _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListViewHandle)) ; Delete the current content _GUICtrlListView_AddArray($ListViewHandle, $Data) ; Add the sorted content EndFunc ;==>RefreshListView [size="2"]The second mouse gets the cheese[/size] 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