bourny Posted May 21, 2009 Share Posted May 21, 2009 I am building a gui and have a couple of issues which I cannot figure out. 1. How do I get the colums to automatically resize to see all the row data 2. I have put a checkbox on each list item - how do I check the box from the script instead of the user checking the box Here is a test script I am playing with #include <GUIConstants.au3> #include <WindowsConstants.au3> #Include <GuiListView.au3> #include <GUIConstantsEx.au3> GUICreate("listview items", 500,500) GUISetBkColor (0x00E0FFFF) ; will change background color Global $listview = GuiCtrlCreateListView ("Application Name | Progress ",-1,-1,200,300,$LVS_SORTDESCENDING, BitOr($LVS_LIST, $LVS_EX_CHECKBOXES)) GuiCtrlCreateListViewItem("1111111111111111111111111|3", $listview) GuiSetState() Sleep(5000) Any help appreciated Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 21, 2009 Moderators Share Posted May 21, 2009 (edited) bourny,Answer to first question. Look at _GUICtrlListView_SetColumnWidth in the Help file. You need to use the $LVSCW_AUTOSIZE parameter AFTER you have entered the data so it knows how wide the column has to become.Answer to second question (I think). Look at _GUICtrlListView_SetItemChecked.M23P.S. You will need to widen your ListView if you want to see it all by the way! ;-)Edit: Pressed Submit too soon! Edited May 21, 2009 by Melba23 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...
Valuater Posted May 21, 2009 Share Posted May 21, 2009 Quick and dirty... #include <GUIConstants.au3> #include <WindowsConstants.au3> #Include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> GUICreate("listview items", 500,500) GUISetBkColor (0x00E0FFFF) ; will change background color Global $listview = GuiCtrlCreateListView ("Application Name | Progress ",-1,-1,300,300,$LVS_SORTDESCENDING, BitOr($LVS_LIST, $LVS_EX_CHECKBOXES)) GuiCtrlCreateListViewItem("1111111111111111111111111|3", $listview) GuiSetState() Sleep(5000) _GUICtrlListView_SetColumnWidth($ListView, 0, 200) Sleep(5000) 8) Link to comment Share on other sites More sharing options...
bourny Posted May 21, 2009 Author Share Posted May 21, 2009 Thanks for that. This now allows me to get the columns automatically rezized. I noticed one other thing...... The width of the GuiCtrlCreateListView has to be set manually to see all the rows. Is there a way I can work out how bit the table needs to be depending on its rows and then center it in the middle of the GUI . Thanks Link to comment Share on other sites More sharing options...
bourny Posted May 21, 2009 Author Share Posted May 21, 2009 I found the following but can only get the width changed automatically the height does not work $iX = _GUICtrlListView_ApproximateViewWidth($listview) _WinAPI_SetWindowPos(GUICtrlGetHandle($listview), 0, 2, 2, $iX, 268, $SWP_NOZORDER) $iY = _GUICtrlListView_ApproximateViewHeight($listview) _WinAPI_SetWindowPos(GUICtrlGetHandle($listview), 0, 2, 2, 394, $iY, $SWP_NOZORDER) Link to comment Share on other sites More sharing options...
bourny Posted May 22, 2009 Author Share Posted May 22, 2009 Does anyone know how to get my above automatic resizing of the table height and width .... I can get the height but the width will not work Here is my script so far #include <GUIConstants.au3> #include <WindowsConstants.au3> #Include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <Constants.au3> GUICreate("listview items", 500,500) GUISetBkColor (0x00E0FFFF) ; will change background color Global $listview = GuiCtrlCreateListView ("Application Name | Progress ",-1,-1,300,400,$LVS_SORTDESCENDING, BitOr($LVS_LIST, $LVS_EX_CHECKBOXES)) GuiCtrlCreateListViewItem("1111111111111111111111111|3", $listview) GuiCtrlCreateListViewItem("22222222222|3", $listview) GuiCtrlCreateListViewItem("333333333333333333333333|3", $listview) GuiCtrlCreateListViewItem("1111111111111111111111111|3", $listview) GuiSetState() _GUICtrlListView_SetColumnWidth($ListView, 0, $LVSCW_AUTOSIZE_USEHEADER ) $iX = _GUICtrlListView_ApproximateViewWidth($listview) _WinAPI_SetWindowPos(GUICtrlGetHandle($listview), 0, 2, 2, $iX, 268, $SWP_NOZORDER) $iY = _GUICtrlListView_ApproximateViewHeight($listview) _WinAPI_SetWindowPos(GUICtrlGetHandle($listview), 0, 2, 2, 394, $iY, $SWP_NOZORDER) Sleep(5000) Many thanks Link to comment Share on other sites More sharing options...
bourny Posted May 22, 2009 Author Share Posted May 22, 2009 Sorry to bump this but I have found it is not the second column that is misbehaving it is the blank column at the end (3rd) that I cannot get rid of. I have looked thru other posts and other posts also seem to have an extra blank column at the end of the table. Does anyone know how to get rid of the last column - I only want to display the 2 I am using - this column makes the GUI look a mess and is unnecessary Any help appreciated Link to comment Share on other sites More sharing options...
bourny Posted May 22, 2009 Author Share Posted May 22, 2009 Found it........ It appears I have the script already defined but it is too gigh up ... I have moved it to the bottom and it appears to strip down the extra unnecessary column My script now after the change expandcollapse popup#include <GUIConstants.au3> #include <WindowsConstants.au3> #Include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <Constants.au3> GUICreate("listview items", 500,500) GUISetBkColor (0x00E0FFF) ; will change background color ;Global $listview = GuiCtrlCreateListView ("Application Name | Progress ",-1,-1,300,400,$LVS_SORTDESCENDING, BitOr($LVS_LIST, $LVS_EX_CHECKBOXES)) Global $listview = GuiCtrlCreateListView ("Application|Progress",-1,-1,0,0) _GUICtrlListView_SetColumnWidth($ListView, 0, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($ListView, 1, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($ListView, 2, $LVSCW_AUTOSIZE_USEHEADER) GuiCtrlCreateListViewItem("1111111111111111111111111|2222|", $listview) GuiCtrlCreateListViewItem("22222222222|222|", $listview) GuiCtrlCreateListViewItem("33333333333333333|33|", $listview) GuiCtrlCreateListViewItem("11111111111111111|444|", $listview) $iY = _GUICtrlListView_ApproximateViewHeight($listview) _WinAPI_SetWindowPos(GUICtrlGetHandle($listview), 0, 2, 2, 394, $iY, $SWP_NOZORDER) $iX = _GUICtrlListView_ApproximateViewWidth($listview) _WinAPI_SetWindowPos(GUICtrlGetHandle($listview), 0, 2, 2, $iX, 268, $SWP_NOZORDER) ;$iX = _GUICtrlListView_ApproximateViewWidth($listview) ;_WinAPI_SetWindowPos(GUICtrlGetHandle($listview), 0, 2, 2, $iX, 268, $SWP_NOZORDER) GuiSetState() Sleep(5000) 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