dotnet / dotnet/winforms

Setting `ListView.CheckBoxes` after `ListView.StateImageList` destroys imagelist

Open
#3,531 2 comments 0 reactions 0 assignees View on GitHub
:beetle: bug :construction: work in progress area-controls-ListView help wanted
Dominant language
C#
Stars
4.9k
Forks
1.1k
Avg merge
20h 23m
Merged PRs (30d)
103

Description

* Have you experienced this same bug with .NET Framework?: Yes

**Problem description:**

An outcome of investigations in https://github.com/dotnet/winforms/issues/3358, in the following scenarios `CheckBoxes` is toggled _whilst_ a user-supplied imagelist is bound to `StateImageList` property - the native listview control will tarnish the user-supplied one.

The issue is reproducible in net4x and netcore3.1.

ListView.CheckBoxes=false

![listview-cb-off](https://user-images.githubusercontent.com/4403806/86293539-21d3b580-bc36-11ea-8cba-a7dfc13e1340.gif)

ListView.CheckBoxes=true

![listview-cb-on](https://user-images.githubusercontent.com/4403806/86294550-184b4d00-bc38-11ea-8f12-cbf7b1236161.gif)

Additionally, it appears changes in one instance of listview *may* affect another, if state imagelist were _similar_ (e.g. contain the same set of images), as the native layer *may* be caching.

Changes to the 2nd listview after tarnishing the first
![listview-cb-cache](https://user-images.githubusercontent.com/4403806/86294407-d3bfb180-bc37-11ea-853d-b4e4398bf1a3.gif)

**Expected behavior:**

Changes `CheckBoxes` property does no affect a user-supplied imagelist.

**Minimal repro:**

https://github.com/RussKie/ListViewCheckboxesStateImageList

Also the issue is easily reproducible in .NET Framework designer by setting up the `StateImageList` property on a `ListView` control, (save), and _then_ setting `CheckBoxes=true`.

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.