dotnet / dotnet/winforms

Discussion/proposal: add more LVCOLUMN ComCtl 6.0 features

Open
#2,627 5 comments 3 reactions 2 assignees Claimed by @lonitra View on GitHub
api-approved area-controls-ListView help wanted tenet-compatibility-OS
Dominant language
C#
Stars
4.9k
Forks
1.1k
Avg merge
1d 13m
Merged PRs (30d)
85

Description

In Windows Vista, more `LVCOLUMN` features were added: see https://docs.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvcolumnw

# Missing Features
## Minimum Width
- Can set the `LVCF_MINWIDTH` flag on `mask` and set the `cxMin` value

Would add the following API on `ColumnHeader`
```cs
public class ColumnHeader
{
...
public int MinimumWidth { get; set; } = 0;
...
}
```

E.g.
Notice that when resizing the column its minimum width is 100 pixels
![Screen Recording 2020-01-04 at 08 25 pm](https://user-images.githubusercontent.com/1275900/71771272-5806d580-2f30-11ea-9176-93d66c29df51.gif)

## Fixed Width Columns
- Can set the `LVCF_FMT` flag on `mask` an set the `LVCFMT_FIXED_WIDTH` flag on `fmt`

Would add the following API on `ColumnHeader`
```cs
public class ColumnHeader
{
...
public bool FixedWidth { get; set; } = false;
...
}
```
E.g.
Notice that the column can't be resized
![umn](https://user-images.githubusercontent.com/1275900/71771287-8f758200-2f30-11ea-97c9-91558019a16b.gif)

## Split Button Columns
- Can set the `LVCF_FMT` flag on `mask` an set the `LVCFMT_SPLITBUTTON` flag on `fmt`

Would add the following API on `ListView` and `ColumnHeader`
```cs
public class ColumnDropDownClickEventArgs : ColumnClickEventArgs
{
public ColumnDropDownClickEventArgs(int column, Point screenLocation);
public Point ScreenLocation { get; set; }
}
public class ListView
{
...
public event ColumnDropDownClickedEventHandler ColumnDropDownClicked { add; remove; }
protected void OnColumnDropDownClicked(ColumnDropDownClickEventArgs e);
...
}
public class ColumnHeader
{
...
public bool SplitButton { get; set; } = false;
...
}
```

E.g.
![Screen Recording 2020-01-04 at 09 15 pm](https://user-images.githubusercontent.com/1275900/71771694-5c82bc80-2f37-11ea-88f6-687a589e146b.gif)

# Discussion
- Should we consolidate things like Split Button and Fixed width into a flags enum and add this as a property (e.g. `Style`) on `ColumnHeader`
```cs
[Flags]
public enum ColumnHeaderStyles
{
None,
FixedWidth = X,
SplitButton = Y
}
```

/cc @weltkante

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.