Skip to content

Commit 5b5f11a

Browse files
CopilotMscrmTools
andcommitted
Preserve entity selection when filtering/searching entities
Co-authored-by: MscrmTools <10774317+MscrmTools@users.noreply.github.com>
1 parent 17b6a2c commit 5b5f11a

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

MsCrmTools.MetadataDocumentGenerator/MetadataDocumentGenerator.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,19 +647,37 @@ private void SaveCurrentSettingsToolStripMenuItemClick(object sender, EventArgs
647647

648648
private void FillListEntities(List<Entities> items)
649649
{
650+
// Save checked state before clearing
651+
var checkedSchemaNames = new HashSet<string>();
652+
foreach (ListViewItem item in lvEntities.Items)
653+
{
654+
if (item.Checked)
655+
{
656+
checkedSchemaNames.Add(item.Tag.ToString());
657+
}
658+
}
659+
650660
lvEntities.Items.Clear();
651661
lvEntities.BeginUpdate();
652662
foreach (var item in items)
653663
{
654-
lvEntities.Items.Add(new ListViewItem
664+
var listViewItem = new ListViewItem
655665
{
656666
Text = item.DisplayName,
657667
SubItems =
658668
{
659669
item.SchemaName
660670
},
661671
Tag = item.SchemaName
662-
});
672+
};
673+
674+
// Restore checked state if this entity was previously checked
675+
if (checkedSchemaNames.Contains(item.SchemaName))
676+
{
677+
listViewItem.Checked = true;
678+
}
679+
680+
lvEntities.Items.Add(listViewItem);
663681
}
664682
lvEntities.EndUpdate();
665683
}

0 commit comments

Comments
 (0)