dotnet / dotnet/winforms

Discussion/Proposal: more ListViewGroup functionality

Open
#2,623 8 comments 4 reactions 2 assignees Claimed by @lonitra View on GitHub
api-suggestion area-controls-ListView help wanted investigate tenet-compatibility-OS
Dominant language
C#
Stars
4.9k
Forks
1.1k
Avg merge
20h 23m
Merged PRs (30d)
103

Description

# State of Play
- Currently, `ListViewGroup` only supports `Header` and `HeaderAlignment` (although this is buggy, see #2555)
- Our definition of `LVGROUPW` is actually too small: LVGROUP actually exposes a lot more functionality (https://docs.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvgroup)
![image](https://user-images.githubusercontent.com/1275900/71745291-9d100680-2e61-11ea-8969-273d50457f55.png)

# Missing Feature Parity
- See http://www.componentowl.com/better-listview.html
- See https://www.codeproject.com/Articles/16009/A-Much-Easier-to-Use-ListView-2
- See https://msdn.microsoft.com/en-gb/msdnmag/issues/07/08/WindowsCPP/default.aspx

## Support For Images
- You can set the `LVSIL_GROUPHEADER` list view image list
- You can set the `LVGF_TITLEIMAGE` flag on `mask` and set `iTitleImage` to a valid index into the `LVSIL_GROUPHEADER` image list

This would add the following APIs to `ListView` and `ListViewGroup`:
```cs
public class ListView
{
...
public ImageList GroupHeaderImageList { get; set; }
...
}
```

```cs
public class ListViewGroup
{
...
public int TitleImageIndex { get; set; }
...
}
```

E.g.
![image](https://user-images.githubusercontent.com/1275900/71745515-40f9b200-2e62-11ea-81cf-a97a9c4c4c27.png)

## Collapsible
- Can set the `LVGF_STATE` flag on `uMask` and set `stateMask` to `LVGS_COLLAPSIBLE` and `state` to `LVGS_COLLAPSIBLE`
- https://www.codeproject.com/Articles/31276/Add-Group-Collapse-Behavior-on-a-Listview-Control

This would add the following APIs to `ListViewGroup`:
```cs
public class ListViewGroup
{
...
public bool Collapsible { get; set; }
...
}
```

E.g.
![Screen Recording 2020-01-03 at 08 10 pm](https://user-images.githubusercontent.com/1275900/71746568-2a088f00-2e65-11ea-9b9d-8f91815c5a8f.gif)

### Discussion
- The rightmost collapse/expand icon doesn't work: to fix this we need to call `base.WndProc` in `WM_LBUTTONUP` handler

## Collapsed
- Can set the `LVGF_STATE` flag on `uMask` and set `stateMask` to `LVGS_COLLAPSED` and `state` to `LVGS_COLLAPSED`

This would add the following APIs to `ListViewGroup`:
```cs
public class ListViewGroup
{
...
public bool Collapsed { get; set; }
...
}
```

E.g.
![Screen Recording 2020-01-04 at 06 57 pm](https://user-images.githubusercontent.com/1275900/71770408-14a66a00-2f24-11ea-89a2-93a01b63cf00.gif)

## HeaderVisible
- Can set the `LVGF_STATE` flag on `uMask` and set `stateMask` to `LVGS_NOHEADER` and `state` to `LVGS_NOHEADER`

This would add the following APIs to `ListViewGroup`:
```cs
public class ListViewGroup
{
...
public bool HeaderVisible { get; set; } = true;
...
}
```

E.g.
![Screen Recording 2020-01-04 at 07 05 pm](https://user-images.githubusercontent.com/1275900/71770510-32c09a00-2f25-11ea-99da-158a88202451.gif)

## Description Top/Bottom
- You can set the `LVGF_DESCRIPTIONTOP` flag on `mask` and set `pszDescriptionTop` to a valid string and `cchDescriptionTop` to the length of the string
- You can set the `LVGF_DESCRIPTIONBOTTOM` flag on `mask` and set `pszDescriptionBottom` to a valid string and `cchDescriptionBottom` to the length of the string

This would add the following APIs to `ListViewGroup`:
```cs
public class ListViewGroup
{
...
public string TopDescription { get; set; }
public string BottomDescription { get; set; }
...
}
```

E.g.
![image](https://user-images.githubusercontent.com/1275900/71770483-d52c4d80-2f24-11ea-8bd0-b9770886042d.png)

/cc @weltkante @RussKie

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.