Skip to content

Commit 8b2c28d

Browse files
committed
Switch log to scroll down with latest message at top.
1 parent c5b8877 commit 8b2c28d

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

SFTPSyncUI/MainForm.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,15 @@ private void AppendLog(string message)
159159

160160
private void AddMessage(string message)
161161
{
162-
listBoxMessages.Items.Add(message);
162+
listBoxMessages.Items.Insert(0, message);
163163

164-
// Optional: auto-scroll to bottom
165-
listBoxMessages.TopIndex = listBoxMessages.Items.Count - 1;
164+
// Keep newest at top
165+
listBoxMessages.TopIndex = 0;
166166

167167
// Optional: trim excess from UI if _log did a dequeue
168168
if (listBoxMessages.Items.Count > 1000)
169169
{
170-
listBoxMessages.Items.RemoveAt(0);
170+
listBoxMessages.Items.RemoveAt(listBoxMessages.Items.Count - 1);
171171
}
172172
}
173173

0 commit comments

Comments
 (0)