hide – Owl's Blog on .NET development http://www.componentowl.com/blog Component Owl codes Better ListView control all night so you don't have to. Tue, 04 Sep 2018 13:10:05 +0000 en-US hourly 1 https://wordpress.org/?v=4.9.8 Hiding Column Headers in Better ListView http://www.componentowl.com/blog/hiding-column-headers-in-better-listview/ http://www.componentowl.com/blog/hiding-column-headers-in-better-listview/#respond Mon, 27 Aug 2012 23:11:27 +0000 http://www.componentowl.com/blog/?p=803 Better ListView 3.2.0 and newer supports hiding column headers but keeping sub-items visible:

Hiding Column Headers

Hiding Column Headers

To hide column headers, simply set HeaderStyle property to BetterListViewHeaderStyle.None. There are other possible styles for all column headers:

  • None – column headers are hidden, but corresponding sub-items are still visible
  • Nonclickable – column headers are visible, but not interactive
  • Clickable – column headers interact with mouse (have hot and pressed state)
  • Sortable – column headers are clickable and sort the corresponding column when clicked
  • Unsortable – same as Sortable, but the column headers have unsorted state as well
  • Hidden – column headers are hidden with corresponding sub-items

These styles can be set on individual column headers as well through BetterListViewColumnHeader.Style property. This property is of type BetterListViewColumnHeaderStyle, which has the same values as BetterListViewHeaderStyle, plus Default value, which means that column header style is inherited from the HeaderStyle property.

When a single column header have style None, that column header is not drawn (only its background is visible) and corresponding sub-items are visible.

When all column headers have style None,  the whole panel with column headers hides (as seen on the above animation) and the sub-items remain visible. This effect is the as when all column headers have style Default and HeaderStyle is set to None.

]]>
http://www.componentowl.com/blog/hiding-column-headers-in-better-listview/feed/ 0
Hiding Items in Better ListView http://www.componentowl.com/blog/hiding-items-in-better-listview/ http://www.componentowl.com/blog/hiding-items-in-better-listview/#respond Mon, 06 Feb 2012 16:23:15 +0000 http://www.componentowl.com/blog/?p=546 We currently introduced a BetterListViewItem.Visible property to allow hiding items visually, but keeping then in the Items collection:

Making items invisible

Making items invisible

The above image shows two groups of items. The first groups uses hiding of items with the Visible property, while the second group simply turns off drawing of ceratin items.

The first approach is useful when you need to hide item as if it is removed, but keep it actually within Items collection.

The second approach need to create new control inheriting from BetterListView, overrride the OnDrawItem method and set properties like BetterListViewDrawItemEventArgs.DrawImage to false or simply not call the base implementation of OnDrawItem.

The second (owner drawing) approach is useful when you need just to switch off display of item without changing the item layout.

]]>
http://www.componentowl.com/blog/hiding-items-in-better-listview/feed/ 0
Custom Behavior of Group Headers in Better ListView http://www.componentowl.com/blog/custom-behavior-of-group-headers-in-better-listview/ http://www.componentowl.com/blog/custom-behavior-of-group-headers-in-better-listview/#respond Fri, 20 Jan 2012 09:40:44 +0000 http://www.componentowl.com/blog/?p=480 When developing our desktop applications, me and Jiri needed to adjust behavior of group headers in the Better ListView control.

We discovered that making group header behavior customizable would be useful not only for us, but for other developers who utilize Better ListView as well, so we implemented this feature officially in Better ListView 2.5.0.

There are two new properties: ShowDefaultGroupHeader and GroupHeaderBehavior.

Hiding the Default Group Header

The ShowDefaultGroupHeader is initially set to true. This means that the default group (the group containing items which do not have a specific group) have its header displayed:

Default group header is visible

Default group header is visible

When ShowDefaultGroupHeader is set to false, the “Default” group header on top can be hidden:

Default group header is hidden

Default group header is hidden

Adjusting Group Header Behavior

The group headers have two kinds of behavior. They can be focused and can cause selection of items. Both of these functions can be invoked by keyboard and mouse.

The GroupHeaderBehavior property allows changing this behavior for keyboard and mouse separately.

By default, the property is set to BetterListViewGroupHeaderBehavior.All, so that all functions of the group header are turned on.

You may want to make group headers completely non-interactive. This can be done by setting the property to BetterListViewGroupHeaderBehavior.None.

Other values of the enum can be combined to create desired behavior.

Keyboard:

  • Focus only
  • Focus and select items in the group

Mouse:

  • Focus
  • Select items in the group
  • Highligh when mouse cursor is over the group header
The expand button of group headers can still be used even if the group header has all the behaviors turned off. If you need to hide the expand button as well, set BetterListViewGroup.AllowShowExpandButton to false.

Use Case: Metadata Viewer

Here Better ListView is used for viewing image metadata tags:

Metadata View window

Metadata View window

Only one tag can be selected at a time, so clicking on a group header has no effect on selection and need not to be highlighted.

One may still need, however, to allow focusing the group header with keyboard and mouse so that it is possible to collapse/expand the group with arrow keys. The desired behavior can be set this way:

C#

[csharp gutter=”false” toolbar=”false”]listView.GroupHeaderBehavior = (BetterListViewGroupHeaderBehavior.KeyboardFocus & BetterListViewGroupHeaderBehavior.MouseFocus);[/csharp]

Visual Basic

[vb gutter=”false” toolbar=”false”]listView.GroupHeaderBehavior = (BetterListViewGroupHeaderBehavior.KeyboardFocus And BetterListViewGroupHeaderBehavior.MouseFocus)[/vb]

]]>
http://www.componentowl.com/blog/custom-behavior-of-group-headers-in-better-listview/feed/ 0
How to Hide a Column in Better ListView http://www.componentowl.com/blog/how-to-hide-a-column-in-better-listview/ http://www.componentowl.com/blog/how-to-hide-a-column-in-better-listview/#respond Fri, 05 Aug 2011 11:56:31 +0000 http://www.componentowl.com/blog/?p=330 The most popular view in ListView-like controls seems to be the “Details” view with columns, items and sub-items.

When someone wants to remove a column, he usually thinks of simply removing the column header from the Columns collection. Unfortunately, it’s not that simple. The sub-items get shifted and he needs to remove sub-items corresponding to the removed column for all items as well.

This is because ListView is not a control for displaying grids (a matrix of cells), but really the lists – sequences of objects, and the sub-items are not cells either, they are something like an extension of each item to support additional information about the item.

So how we neatly hide a column?

We introduced Column Hiding feature in the version 2.0.1. You can simply call Hide() on your column header instance and you’re done! There is also corresponding Show() method provided. Or you can set boolean Visible property. Now the column and all subsequent sub-items are hidden from view (although they are still present in data, of course):

 

Hiding column via context menu

Hiding column via context menu...

 

The sixth column is hidden...

...and the sixth column gets hidden.

 

Download Better ListView

]]>
http://www.componentowl.com/blog/how-to-hide-a-column-in-better-listview/feed/ 0