winforms icon indicating copy to clipboard operation
winforms copied to clipboard

The "ListView" property is not set for a ListViewGroup when a ListViewItem with this ListViewGroup is added to the ListView

Open SergeySmirnov-Akvelon opened this issue 5 years ago • 0 comments

Is your feature request related to a problem? Please describe. If user creates ListViewGroup, creates ListViewItem that linked to this ListViewGroup and adds ListViewItem to ListView then ListViewGroup does not appear in ListView. As a result ListView has ListViewItem linked with a ListViewGroup that is not associated with ListView. After execution of following code:

var listViewGroup = new ListViewGroup("Test group");
var listViewItem = new ListViewItem("Test item", listViewGroup);
listView.Items.Add(listViewItem);

ListViewGroup will not be displayed in ListView. Property "ListView" also will be empty for ListViewGroup.

Describe the solution you'd like and alternatives you've considered I suggest to add ListViewGroup to ListView when user adds ListViewItem that associated with ListViewGroup. As a result if user executes code above then:

  • ListViewGroup should be added to ListView and should be displayed in ListView.Groups collection
  • ListView property of ListViewGroup should have ListView to which the ListViewItem was added
  • If ListViewGroup already has another ListView then we should throw IOE.

Also it will avoid the case where the user has ListViewItems that linked to a ListViewGroup but forgot to add the ListViewGroup to the ListView

Will this feature affect UI controls? This issue is specific for ListView. Also it will help to avoid problem with ListViewGroupAccessibleObject, because we can not get AccessibleObject for ListViewGroup when it has not ListView.

SergeySmirnov-Akvelon avatar Sep 28 '20 12:09 SergeySmirnov-Akvelon