Difference between revisions of "ListView"

From AutoIt Wiki
Jump to navigation Jump to search
(Related links: added Listview flicker when in tab item)
m
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
=ListViews And How To Deal With Them=
+
{{WIP}}
 +
= ListViews And How To Deal With Them =
  
ListViews ...  
+
== Fill with data ==
 +
... Work in progress ...
  
 +
== Sort ==
 +
... Work in progress ...
  
=Related links=
+
== Set alternate color ==
 +
ListViews with a large number of rows and/or columns are much easier to read when the background color of the lines alternates. You might remember paper used for printouts in mainframe computer days. The color alternated between white and light green (or some other light colors) [[http://en.wikipedia.org/wiki/File:Endlospapier_fan-fold_paper.jpg]].<br />
 +
This can be done with ListViews as well:<br />
 +
[[File:ListView_Alternate_Color_Green.png]]<br />
 +
 
 +
Flag $GUI_BKCOLOR_LV_ALTERNATE is used to alternate the color of the listview item lines. Odd lines will get the color set for the Listview control, even lines will get the color set for the ListviewItem control.<br />
 +
Example:
 +
<syntaxhighlight lang="autoit">
 +
#include <GUIConstantsEx.au3>
 +
#include <ColorConstants.au3>
 +
GUICreate("listview items", 220, 250, 100, 200, -1)
 +
Global $idListview = GUICtrlCreateListView("col1  |col2|col3  ", 10, 10, 200, 150)
 +
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_LV_ALTERNATE) ; alternate between the listview background color and the listview item background color
 +
GUICtrlSetBkColor(-1, $COLOR_AQUA) ; Set the background color for the listview
 +
GUICtrlCreateListViewItem("item1|col12|col13", $idListview)
 +
GUICtrlCreateListViewItem("item2|col22|col23", $idListview)
 +
GUICtrlSetBkColor(-1, $COLOR_TEAL) ; Set the background color for the listview item
 +
GUICtrlCreateListViewItem("item3|col32|col33", $idListview)
 +
GUICtrlCreateListViewItem("Now|change|color", $idListview)
 +
GUICtrlSetBkColor(-1, $COLOR_RED) ; Set the background color for the listview item
 +
GUICtrlCreateListViewItem("item5|col52|col53", $idListview)
 +
GUICtrlCreateListViewItem("item6|col62|col63", $idListview)
 +
GUICtrlSetBkColor(-1, $COLOR_TEAL) ; Set the background color for the listview item
 +
GUISetState(@SW_SHOW)
 +
While 1
 +
    Switch GUIGetMsg()
 +
        Case $GUI_EVENT_CLOSE
 +
            Exit
 +
    EndSwitch
 +
WEnd
 +
</syntaxhighlight>
 +
Will result in:<br />
 +
[[File:ListView Alternate Color.png|Alternate ListView item lines.]]<br />
 +
 
 +
==Related links==
 
Below Links to interesting topics in the forum related to the use of ListView
 
Below Links to interesting topics in the forum related to the use of ListView
 
* [http://www.autoitscript.com/forum/index.php?showtopic=181346 Colors and fonts in custom drawn ListViews - UDF version (by LarsJ)]
 
* [http://www.autoitscript.com/forum/index.php?showtopic=181346 Colors and fonts in custom drawn ListViews - UDF version (by LarsJ)]

Latest revision as of 13:50, 15 May 2016

This page is still a work in progress.

ListViews And How To Deal With Them

Fill with data

... Work in progress ...

Sort

... Work in progress ...

Set alternate color

ListViews with a large number of rows and/or columns are much easier to read when the background color of the lines alternates. You might remember paper used for printouts in mainframe computer days. The color alternated between white and light green (or some other light colors) [[1]].
This can be done with ListViews as well:
ListView Alternate Color Green.png

Flag $GUI_BKCOLOR_LV_ALTERNATE is used to alternate the color of the listview item lines. Odd lines will get the color set for the Listview control, even lines will get the color set for the ListviewItem control.
Example:

#include <GUIConstantsEx.au3>
#include <ColorConstants.au3>
GUICreate("listview items", 220, 250, 100, 200, -1)
Global $idListview = GUICtrlCreateListView("col1  |col2|col3  ", 10, 10, 200, 150)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_LV_ALTERNATE) ; alternate between the listview background color and the listview item background color
GUICtrlSetBkColor(-1, $COLOR_AQUA) ; Set the background color for the listview
GUICtrlCreateListViewItem("item1|col12|col13", $idListview)
GUICtrlCreateListViewItem("item2|col22|col23", $idListview)
GUICtrlSetBkColor(-1, $COLOR_TEAL) ; Set the background color for the listview item
GUICtrlCreateListViewItem("item3|col32|col33", $idListview)
GUICtrlCreateListViewItem("Now|change|color", $idListview)
GUICtrlSetBkColor(-1, $COLOR_RED) ; Set the background color for the listview item
GUICtrlCreateListViewItem("item5|col52|col53", $idListview)
GUICtrlCreateListViewItem("item6|col62|col63", $idListview)
GUICtrlSetBkColor(-1, $COLOR_TEAL) ; Set the background color for the listview item
GUISetState(@SW_SHOW)
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Will result in:
Alternate ListView item lines.

Related links

Below Links to interesting topics in the forum related to the use of ListView