Jump to content

Gui List control


Recommended Posts

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

  • Moderators

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.

M23

P.S. You will need to widen your ListView if you want to see it all by the way! ;-)

Edit: Pressed Submit too soon!

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

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)

NEWHeader1.png

Link to comment
Share on other sites

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

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

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

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

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

#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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...