{"id":3793,"date":"2012-04-04T14:00:35","date_gmt":"2012-04-04T22:00:35","guid":{"rendered":"http:\/\/www.sapien.com\/blog\/?p=3793"},"modified":"2013-02-25T13:19:30","modified_gmt":"2013-02-25T21:19:30","slug":"spotlight-on-the-listview-control-part-1","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2012\/04\/04\/spotlight-on-the-listview-control-part-1\/","title":{"rendered":"Spotlight on the ListView Control &#8211; Part 1"},"content":{"rendered":"<p><em>The \u201cSpotlight on Controls\u201d series focuses on a single WinForms control in PrimalForms 2011 , details the important Properties, Methods, and Events of the control and demonstrates how to utilize the control. Most of the information about the controls is still applicable to previous versions of PrimalForms.<\/em><\/p>\n<p>Last time we took a look at the ContextMenuStrip . This time we will look at the ListView control:<\/p>\n<p><span style=\"font-size: medium\"><strong>ListView <\/strong>[System.Windows.Forms.ListView]<\/span><\/p>\n<p>Represents a Windows list view control, which displays a collection of items that can be displayed using one of four different views.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"ListView Toolbox Item\" border=\"0\" alt=\"ListView Toolbox Item\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/02\/ListView-Toolbox-Item.png\" width=\"88\" height=\"20\"><\/p>\n<p>Default Event: SelectedIndexChanged<\/p>\n<p><em>Why use a ListView control?<\/em><\/p>\n<p>The ListView is a hybrid display. It is more complex then a ListBox, but also can display data similar to a grid. A ListView control allows you to display a list of items with item text and, optionally, an icon to identify the type of item. For example, you could use the ListView to display icons in a similar fashion to the Window\u2019s File Explorer.<\/p>\n<p><em><span style=\"color: #ff0000\">Note: Requires PrimalForms 2011 v2.0.20 and above to utilize some of the following ListView features.<\/span><\/em><\/p>\n<p><strong><span style=\"font-size: small\">Important Properties:<\/span><\/strong><\/p>\n<p><strong>View<\/strong><\/p>\n<p>This property indicates how items are displayed in the control. Use this property to set the style or view of the ListView control.<\/p>\n<p>Select from the following views:<\/p>\n<blockquote>\n<p><em>LargeIcon<\/em><br \/>Each item appears as a full-sized icon with a label below it.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"LargeIcon View\" border=\"0\" alt=\"LargeIcon View\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/02\/LargeIcon-View.png\" width=\"253\" height=\"139\"><\/p>\n<p><em>Details<\/em><br \/>Each item appears on a separate line with further information about each item arranged in columns. The left-most column contains a small icon and label, and subsequent columns contain sub items as specified by the application. A column displays a header which can display a caption for the column. The user can resize each column at run time.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"Details View\" border=\"0\" alt=\"Details View\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/02\/Details-View.png\" width=\"253\" height=\"122\"><\/p>\n<p><em>SmallIcon<\/em><br \/>Each item appears as a small icon with a label to its right.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"SmallIcon View\" border=\"0\" alt=\"SmallIcon View\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/02\/SmallIcon-View.png\" width=\"253\" height=\"101\"><\/p>\n<p><em>List<\/em><br \/>Each item appears as a small icon with a label to its right. Items are arranged in columns with no column headers.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"List View\" border=\"0\" alt=\"List View\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/02\/List-View.png\" width=\"253\" height=\"111\"><\/p>\n<p><em>Tile<\/em><br \/>Each item appears as a full-sized icon with the item label and subitem information to the right of it. The subitem information that appears is specified by the application. This view is available only on Windows XP and the Windows Server 2003 family. On earlier operating systems, this value is ignored and the ListView control displays in the LargeIcon view.<\/p>\n<\/blockquote>\n<blockquote>\n<p><strong><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"Tile View\" border=\"0\" alt=\"Tile View\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/02\/Tile-View.png\" width=\"253\" height=\"187\"><\/strong><\/p>\n<\/blockquote>\n<p>Note: Some properties only pertain to particular views. The compatible views will be listed in each property\u2019s description.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Alignment<\/strong><\/p>\n<p>This property indicates how items are aligned within the ListView.<\/p>\n<p>Compatible Views: <em>SmallIcon, <\/em><em>LargeIcon<\/em><\/p>\n<p>Default Value:<em> Top<\/em><\/p>\n<blockquote>\n<p><em>Default<\/em><br \/>When the user moves an item, it remains where it is dropped.<\/p>\n<p><em>Top<\/em><br \/>Items are aligned to the top of the ListView control.<\/p>\n<p><em>Left<\/em><br \/>Items are aligned to the left of the ListView control.<\/p>\n<p><em>SnapToGrid<\/em><br \/>Items are aligned to an invisible grid in the control. When the user moves an item, it moves to the closest juncture in the grid.<\/p>\n<\/blockquote>\n<p><strong>AllowColumnReorder<\/strong><\/p>\n<p>This property indicates whether the user can reorder column headers in the Details view. Set this property to True, the users the order of the column header, by dragging the header to the desired location.<\/p>\n<p>Compatible Views: <em>Details<\/em><\/p>\n<p>Default Value: <em>False<\/em><\/p>\n<p><strong><\/strong><\/p>\n<p><strong>CheckBoxes<\/strong><\/p>\n<p>This property indicates whether a check box appears next to each item in the control.<\/p>\n<p>Compatible Views: All except <em>Tile<\/em><\/p>\n<p>Default Value: <em>False<\/em><\/p>\n<p>When CheckBoxes is set to <em>True<\/em>, use the ItemChecked event to respond to an item\u2019s checked state changes.<\/p>\n<p><strong><strong><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"CheckBoxes\" border=\"0\" alt=\"CheckBoxes\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/02\/CheckBoxes.png\" width=\"207\" height=\"119\"><\/strong><\/strong><\/p>\n<p><strong><\/strong><\/p>\n<p><strong>Columns<\/strong><\/p>\n<p>This property contains a collection of column headers that are displayed in the Details view.<\/p>\n<p>Compatible Views: <em>Details<\/em><\/p>\n<p>You can access the ColumnHeader Collection Editor via the designer:<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/02\/Edit-Columns-Designer.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"Edit Columns Designer\" border=\"0\" alt=\"Edit Columns Designer\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/02\/Edit-Columns-Designer_thumb.png\" width=\"244\" height=\"178\"><\/a><\/p>\n<p>Or you can access the ColumnHeader Collection Editor via the Property Pane:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"Edit Columns Property Pane\" border=\"0\" alt=\"Edit Columns Property Pane\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/02\/Edit-Columns-Property-Pane.png\" width=\"207\" height=\"99\"><\/p>\n<p>The ColumnHeader Collection Editor allows you to add \/ remove Column as well as modify their properties:<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/02\/ColumnHeader-Collection-Editor.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"ColumnHeader Collection Editor\" border=\"0\" alt=\"ColumnHeader Collection Editor\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/02\/ColumnHeader-Collection-Editor_thumb.png\" width=\"244\" height=\"180\"><\/a><\/p>\n<p>The Columns collection is made up of the following object:<\/p>\n<p><strong>ColumnHeader<\/strong> [System.Windows.Forms.ColumnHeader ]<\/p>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\" width=\"450\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"127\"><strong>Property<\/strong><\/td>\n<td valign=\"top\" width=\"323\"><strong>Description<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"127\">DisplayIndex<\/td>\n<td valign=\"top\" width=\"323\">This property indicates the display order of the column relative to the currently displayed columns<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"127\">ImageIndex<\/td>\n<td valign=\"top\" width=\"323\">This property indicates the index of the image displayed in the ColumnHeader.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"127\">Text<\/td>\n<td valign=\"top\" width=\"323\">This property contains the text displayed in the column header.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"127\">TextAlign<\/td>\n<td valign=\"top\" width=\"323\">This property determines the horizontal alignment of the text displayed in the ColumnHeader.<br \/>Values (Default: <em>Left<\/em>):<br \/><em>Left<\/em><br \/>The object or text is aligned on the left of the control element.  <\/p>\n<p><em>Right<\/em><br \/>The object or text is aligned on the right of the control element.<\/p>\n<p><em>Center<\/em><br \/>The object or text is aligned in the center of the control element.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"127\">Width<\/td>\n<td valign=\"top\" width=\"323\">This property determines the width of the column.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Set Width = -1, to adjust the width of the longest item in the column.<br \/>Set Width = -2, to auto size to the width of the column heading.<br \/>Note: When setting these special values, the control will automatically replace the Width with the calculated value.<\/p>\n<p><strong><\/strong>You can use the Column\u2019s <em>Add<\/em> method to add Columns via the script editor:<\/p>\n<p>Add Methods:<\/p>\n<p><span style=\"font-size: x-small\"><span style=\"color: #0000ff\">[int]<\/span> <span style=\"color: #4bacc6\">Add <\/span>(<span style=\"color: #0000ff\">[ColumnHeader] <\/span><span style=\"color: #000000\">value<\/span>)<br \/>Adds an existing ColumnHeader to the collection. <\/span><\/p>\n<p><span style=\"font-size: x-small\"><br \/><span style=\"color: #0000ff\">[ColumnHeader]<\/span> <span style=\"color: #4bacc6\">Add <\/span>(<span style=\"color: #0000ff\">[<\/span><span style=\"color: #0000ff\">String] <\/span><span style=\"color: #000000\">text)<br \/>Creates and adds a column with the specified text to the collection. <\/span><\/span><\/p>\n<p><span style=\"font-size: x-small\"><br \/><span style=\"color: #0000ff\">[ColumnHeader] <\/span><span style=\"color: #4bacc6\">Add <\/span>(<span style=\"color: #0000ff\">[<\/span><span style=\"color: #0000ff\">String] <span style=\"color: #000000\">text<\/span><\/span>, <span style=\"color: #0000ff\">[int] <\/span><span style=\"color: #000000\">width<\/span>)<br \/>Creates and adds a column with the specified text and width to the collection. <\/span><\/p>\n<p><span style=\"font-size: x-small\"><br \/><span style=\"color: #0000ff\">[ColumnHeader] <\/span><span style=\"color: #4bacc6\">Add <\/span>(<span style=\"color: #0000ff\">[<\/span><span style=\"color: #0000ff\">String] <span style=\"color: #000000\">key<\/span><\/span>, <span style=\"color: #0000ff\">[<\/span><span style=\"color: #0000ff\">String] <span style=\"color: #000000\">text<\/span><\/span>)<br \/>Creates and adds a column with the specified text and key to the collection. <\/span><\/p>\n<p><span style=\"font-size: x-small\"><br \/><span style=\"color: #0000ff\">[ColumnHeader] <\/span><span style=\"color: #4bacc6\">Add <\/span>(<span style=\"color: #0000ff\">[<\/span><span style=\"color: #0000ff\">String] <span style=\"color: #000000\">text<\/span><\/span>, <span style=\"color: #0000ff\">[int] <span style=\"color: #000000\">width<\/span><\/span>, <span style=\"color: #0000ff\">[<\/span><span style=\"color: #0000ff\">HorizontalAlignment] <span style=\"color: #000000\">textAlign<\/span><\/span>)<br \/>Adds a column header to the collection with specified text, width, and alignment settings. <\/span><\/p>\n<p><span style=\"font-size: x-small\"><br \/><span style=\"color: #0000ff\">[ColumnHeader] <\/span><span style=\"color: #4bacc6\">Add <\/span>(<span style=\"color: #0000ff\">[<\/span><span style=\"color: #0000ff\">String] <\/span><span style=\"color: #000000\">key<\/span>, <span style=\"color: #0000ff\">[<\/span><span style=\"color: #0000ff\">String] <span style=\"color: #000000\">text<\/span><\/span>, <span style=\"color: #0000ff\">[int] <\/span><span style=\"color: #000000\">width<\/span>)<br \/>Creates and adds a&nbsp; column with the specified text, key, and width to the collection. <\/span><\/p>\n<p><span style=\"font-size: x-small\"><br \/><span style=\"color: #0000ff\">[ColumnHeader] <\/span><span style=\"color: #4bacc6\">Add <\/span>(<span style=\"color: #0000ff\">[<\/span><span style=\"color: #0000ff\">String] <span style=\"color: #000000\">key<\/span><\/span>, <span style=\"color: #0000ff\">[<\/span><span style=\"color: #0000ff\">String] <span style=\"color: #000000\">text<\/span><\/span>, <span style=\"color: #0000ff\">[int] <span style=\"color: #000000\">width<\/span><\/span>, <span style=\"color: #0000ff\">[<\/span><span style=\"color: #0000ff\">HorizontalAlignment] <\/span><span style=\"color: #000000\">textAlign<\/span>, <span style=\"color: #0000ff\">[int] <span style=\"color: #000000\">imageIndex<\/span><\/span>)<br \/>Creates and adds a column with the specified key, aligned text, width, and image index to the collection. <\/span><\/p>\n<p><span style=\"font-size: x-small\"><br \/><span style=\"color: #0000ff\">[ColumnHeader] <\/span><span style=\"color: #4bacc6\">Add <\/span>(<span style=\"color: #0000ff\">[<\/span><span style=\"color: #0000ff\">String] <\/span><span style=\"color: #000000\">key<\/span>, <span style=\"color: #0000ff\">[<\/span><span style=\"color: #0000ff\">String] <span style=\"color: #000000\">text<\/span><\/span>, <span style=\"color: #0000ff\">[int] <span style=\"color: #000000\">width<\/span><\/span>, <span style=\"color: #0000ff\">[<\/span><span style=\"color: #0000ff\">HorizontalAlignment] <span style=\"color: #000000\">textAlign<\/span><\/span>, <span style=\"color: #0000ff\">[<\/span><span style=\"color: #0000ff\">String] <\/span><span style=\"color: #000000\">imageKey<\/span>)<br \/>Creates and add s a column with the specified key, aligned text, width, and image key to the collection.<\/span><\/p>\n<p>Example Use:<\/p>\n<pre><span style=\"color: #8b0000\">$columnApplication <\/span><span style=\"color: #0000ff\">= <\/span><span style=\"color: #8b0000\">$listview1<\/span><span style=\"color: #000000\">.Columns.Add(<\/span><span style=\"color: #ff0000\">\"Application\"<\/span><span style=\"color: #000000\">) <\/span><\/pre>\n<pre><span style=\"color: #000000\"><\/span><span style=\"color: #8b0000\">$columnInstalled <\/span><span style=\"color: #0000ff\">= <\/span><span style=\"color: #8b0000\">$listview1<\/span><span style=\"color: #000000\">.Columns.Add(<\/span><span style=\"color: #ff0000\">\"Installed\"<\/span><span style=\"color: #000000\">)<\/span><\/pre>\n<p>&nbsp;<\/p>\n<p><strong>FullRowSelect<\/strong><\/p>\n<p>This property indicates whether all sub items are highlighted along with the item when selected.<\/p>\n<p>Compatible Views: <em>Details<\/em><\/p>\n<p><strong><\/strong>Default Value: <em>False<\/em><\/p>\n<p>Selection without FullRowSelect:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"FullRowSelect False\" border=\"0\" alt=\"FullRowSelect False\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/02\/FullRowSelect-False.png\" width=\"234\" height=\"122\"><\/p>\n<p>Selection with FullRowSelect:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"FullRowSelect True\" border=\"0\" alt=\"FullRowSelect True\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/02\/FullRowSelect-True.png\" width=\"210\" height=\"125\"><\/p>\n<p>&nbsp;<\/p>\n<p><strong>GridLines<\/strong><\/p>\n<p>This property indicates whether grid lines appear between the rows and columns containing the items and sub items in the control. The grid lines are only shown when in Details view.<\/p>\n<p>Compatible Views: <em>Details<\/em><\/p>\n<p><em><\/em>&nbsp;<img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"Gridlines\" border=\"0\" alt=\"Gridlines\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/02\/Gridlines.png\" width=\"244\" height=\"119\"><\/p>\n<p><strong>Groups<\/strong><\/p>\n<p>This property contains a collection of ListViewGroup objects that are used by the control. Groups are very useful to display items in categories within the ListView.<\/p>\n<p>Note: If there are groups defined and a item has no group set, it will go into the \u201cDefault\u201d group.<\/p>\n<p>Compatible Views: All except the <em>List<\/em><\/p>\n<p><em><\/em><\/p>\n<p>You can access the Group Collection Editor via the Designer:<\/p>\n<p><strong><\/strong>&nbsp;<a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/02\/Edit-Columns-Designer1.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"Edit Columns Designer\" border=\"0\" alt=\"Edit Columns Designer\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/02\/Edit-Columns-Designer_thumb1.png\" width=\"244\" height=\"178\"><\/a><\/p>\n<p>Or via the Property Pane:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"Groups via Property Pane\" border=\"0\" alt=\"Groups via Property Pane\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/02\/Groups-via-Property-Pane.png\" width=\"207\" height=\"102\"><\/p>\n<p>&nbsp;<\/p>\n<p>The ListViewGroup Collection Editor allows you to add \/ remove groups:<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/02\/ListViewGroup-Editor.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"ListViewGroup Editor\" border=\"0\" alt=\"ListViewGroup Editor\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/02\/ListViewGroup-Editor_thumb.png\" width=\"244\" height=\"180\"><\/a><\/p>\n<p>The Group collection is made up of the following object:<\/p>\n<p><strong>ListViewGroup<\/strong> [System.Windows.Forms.ListViewGroup]<\/p>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\" width=\"472\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"124\"><strong>Property<\/strong><\/td>\n<td valign=\"top\" width=\"346\"><strong>Description<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"124\">Header<\/td>\n<td valign=\"top\" width=\"346\">This property sets the header text for the group.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"124\">HeaderAlignment<\/td>\n<td valign=\"top\" width=\"346\">This property sets the alignment of the group header text.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Values (Default: <em>Left<\/em>):<\/p>\n<p><em>Left<\/em><br \/>The object or text is aligned on the left of the control element.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"Group Alignment Left\" border=\"0\" alt=\"Group Alignment Left\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/02\/Group-Alignment-Left.png\" width=\"318\" height=\"24\"><\/p>\n<p><em>Right<\/em><br \/>The object or text is aligned on the right of the control element.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"Group Alignment Right\" border=\"0\" alt=\"Group Alignment Right\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/02\/Group-Alignment-Right.png\" width=\"318\" height=\"24\"><\/p>\n<p><em>Center<\/em><br \/>The object or text is aligned in the center of the control element.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"Group Alignment Center\" border=\"0\" alt=\"Group Alignment Center\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/02\/Group-Alignment-Center.png\" width=\"318\" height=\"24\"><\/p>\n<p>Adding groups via the Script Editor:<\/p>\n<p><span style=\"font-size: x-small\"><span style=\"color: #0000ff\">[int]<\/span> <span style=\"color: #4bacc6\">Add <\/span>(<span style=\"color: #0000ff\">[<\/span><span style=\"color: #0000ff\">ListViewGroup] <\/span><span style=\"color: #000000\">group<\/span>)<br \/>Adds the specified ListViewGroup to the collection.<\/span><\/p>\n<p><span style=\"font-size: x-small\"><span style=\"color: #0000ff\">[ListViewGroup] <\/span><span style=\"color: #4bacc6\">Add <\/span>(<span style=\"color: #0000ff\">[<\/span><span style=\"color: #0000ff\">String] <\/span><span style=\"color: #000000\">key<\/span>, <span style=\"color: #0000ff\">[<\/span><span style=\"color: #0000ff\">String] <\/span><span style=\"color: #000000\">headerText<\/span>)<br \/>Adds a new ListViewGroup to the collection using the specified values to initialize the Name and Header properties<\/span><\/p>\n<p>Example Use:<\/p>\n<pre><span style=\"color: #8b0000\">$listview1<\/span><span style=\"color: #000000\">.Groups.Add(<\/span><span style=\"color: #ff0000\">\"InstallGroup\"<\/span><span style=\"color: #000000\">, <\/span><span style=\"color: #ff0000\">\"Installed\"<\/span><span style=\"color: #000000\">)<\/span><\/pre>\n<p><strong>ShowGroups<\/strong><\/p>\n<p>This property indicates whether items are displayed in groups.<\/p>\n<p>Compatible Views: <em>Details, <em>LargeIcon, SmallIcon, Tile<\/em><\/em><\/p>\n<p><strong><\/strong>Default Value: <em>True<\/em><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"ListView with Groups\" border=\"0\" alt=\"ListView with Groups\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/02\/ListView-with-Groups.png\" width=\"291\" height=\"170\"><\/p>\n<p><strong>HeaderStyle<\/strong><\/p>\n<p>This property indicated the style of the column headers in the Details view. Use this property when you want to prevent the users from having the option to click on the headers. Typically you would want to sort the items when a user clicks on the header. You can respond to a header click by using the ListView\u2019s ColumnClick event.<\/p>\n<p>Compatible Views: <em>Details<\/em><\/p>\n<p><strong><\/strong>Values (Default: <em>Clickable<\/em>):<\/p>\n<blockquote>\n<p><em>None<\/em><br \/>The column header is not displayed in report view.<\/p>\n<p><em>Nonclickable<\/em><br \/>The column headers do not respond to the click of a mouse.<\/p>\n<p><em>Clickable<\/em><br \/>The column headers function like buttons and can carry out an action, such as sorting, when clicked.<\/p>\n<\/blockquote>\n<p><strong>HideSelection<\/strong><\/p>\n<p>This property indicates whether the selected item in the control remains highlighted when the control loses focus.<\/p>\n<p>Compatible Views: All<\/p>\n<p><strong><\/strong><\/p>\n<p><strong>HotTracking<\/strong><\/p>\n<p>This property indicates whether the text of an item or subitem has the appearance of a hyperlink when the mouse pointer passes over it.<\/p>\n<p>Enabling hot tracking will cause the Activation property to be set to OneClick and the HoverSelection property to be set to true. In addition, run-time label editing is not allowed when hot tracking is enabled.<\/p>\n<p>Compatible Views: All<\/p>\n<p><strong><\/strong>Default Value: <em>False<\/em><\/p>\n<p><strong>LabelEdit<\/strong><\/p>\n<p>This property indicates whether the user can edit the labels of items in the control.&nbsp; Use the BeforeEditLabel and AfterEditLabel events in order react to when a user changes a label.<\/p>\n<p>Compatible Views: All<\/p>\n<p>Default Value: <em>False<\/em><\/p>\n<p><strong>LargeImageList<\/strong><\/p>\n<p>This property contains the ImageList control used by the ListView for images in Large Icon view.&nbsp; See the Spotlight on the ImageList Control blog article for more information on the ImageList.<\/p>\n<p>Note: The index of the corresponding SmallImageList should be the same as the LargeImageList.<\/p>\n<p>Compatible Views: <em>LargeIcon<\/em><\/p>\n<p><strong><\/strong><\/p>\n<p><strong>SmallImageList<\/strong><\/p>\n<p>This property contains the ImageList control used by the ListView for images in all views except for the Large Icon view.<\/p>\n<p>Compatible Views: <em>SmallIcon, Detail, List, Tile<\/em><\/p>\n<p>&nbsp;<\/p>\n<p><strong>StateImageList<\/strong><\/p>\n<p>This property contains the ImageList control used by the ListView for custom states.<\/p>\n<p>Note: If an ImageList is specified in the StateImageList property and the CheckBoxes property is set to true, the images at index positions 0 and 1 in the ImageList are displayed instead of the check box. The image at index position 0 is displayed instead of the unchecked check box, and the image at index position 1 is displayed instead of the checked check box.<\/p>\n<p>Compatible Views: All<\/p>\n<p>&nbsp;<\/p>\n<p><strong>MultiSelect<\/strong><\/p>\n<p>This property indicating whether multiple items can be selected. If this property is set to true, use the SelectedItems property to determine which items are selected.<\/p>\n<p>Compatible Views: All<\/p>\n<p><strong><\/strong>Default Value: <em>True<\/em><\/p>\n<p><em><\/em><\/p>\n<p><strong>ShowItemToolTips<\/strong><\/p>\n<p>This property indicates whether ToolTips are shown for the ListViewItem objects contained in the ListView.<\/p>\n<p>Compatible Views: All<\/p>\n<p><strong><\/strong>Default Value: <em>False<\/em><\/p>\n<p><em><\/em><\/p>\n<p><strong>Sorting<\/strong><\/p>\n<p>This property indicates the manner in which items are to be sorted.<\/p>\n<p>Default Value: None<\/p>\n<blockquote>\n<p><em>None<\/em><br \/>The items are not sorted.<\/p>\n<p><em>Ascending<\/em><br \/>The items are sorted in ascending order.<\/p>\n<p><em>Descending<\/em><br \/>The items are sorted in descending order.<\/p>\n<\/blockquote>\n<p>Compatible Views: All<\/p>\n<p><strong><\/strong><\/p>\n<p><strong>SelectedItems<\/strong><\/p>\n<p>This property contains all the items that are selected in the ListView. Note: Each item is a ListViewItem object, so you will have to use the Text property to display the name. The ListViewItem will be addressed in Part 2.<\/p>\n<pre><span style=\"color: #008000\">#Display Selected Items<br><\/span><span style=\"color: #0000ff\">foreach<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #8b0000\">$item<\/span><span style=\"color: #0000ff\">in<\/span><span style=\"color: #8b0000\">$listview1<\/span><span style=\"color: #000000\">.SelectedItems)<br>{ <br>   <\/span><span style=\"color: #0000ff; font-weight: bold\">Write-Host <\/span><span style=\"color: #8b0000\">$item<\/span><span style=\"color: #000000\">.Text<br>}<\/span><\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Next:<\/strong> <a href=\"http:\/\/www.sapien.com\/blog\/2012\/04\/05\/spotlight-on-the-listview-control-part-2\/\">Part 2<\/a> \u2013 Adding Items, Methods and Events<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The \u201cSpotlight on Controls\u201d series focuses on a single WinForms control in PrimalForms 2011 , details the important Properties, Methods, and Events of the control and demonstrates how to utilize the control. Most of the information about the controls is still applicable to previous versions of PrimalForms. Last time we took a look at the [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[509,575,644,25],"tags":[641,699,28,633,327],"class_list":["post-3793","post","type-post","status-publish","format-standard","hentry","category-primalforms-software-news","category-primalforms-2011-software-news","category-spotlight-on-controls","category-windows-powershell","tag-controls","tag-listview","tag-powershell","tag-primalforms-2011","tag-winform"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/3793","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=3793"}],"version-history":[{"count":7,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/3793\/revisions"}],"predecessor-version":[{"id":5750,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/3793\/revisions\/5750"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=3793"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=3793"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=3793"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}