Fix Nodes auto-closing right after expanding via Right key. (#2021)

Fix Nodes not saving Expanded when opening or closing via Left and Right key.
This commit is contained in:
Blacktempel
2025-11-09 13:30:30 +01:00
committed by GitHub
parent c542e856d4
commit 43e728f1de
2 changed files with 23 additions and 2 deletions
+22 -2
View File
@@ -937,8 +937,6 @@ public sealed partial class MainForm : Form
if (!backgroundUpdater.IsBusy)
backgroundUpdater.RunWorkerAsync();
RestoreCollapsedNodeState(treeView);
}
private void SaveConfiguration()
@@ -1360,6 +1358,28 @@ public sealed partial class MainForm : Form
treeView.Columns[0].Width = newWidth;
}
private void TreeView_KeyDown(object sender, KeyEventArgs e)
{
if (treeView.SelectedNode != null)
{
switch (e.KeyCode)
{
case Keys.Right:
if (treeView.SelectedNode.Tag is IExpandPersistNode expandPersistNodeR)
{
expandPersistNodeR.Expanded = true;
}
return;
case Keys.Left:
if (treeView.SelectedNode.Tag is IExpandPersistNode expandPersistNodeL)
{
expandPersistNodeL.Expanded = false;
}
return;
}
}
}
private void TreeView_ColumnWidthChanged(TreeColumn column)
{
int index = treeView.Columns.IndexOf(column);