How to auto scroll down in ListView control when update new item?
I have tried
listView1.Focus();
listView1.Items[listView1.Items.Count - 1].Selected = true;
but this not working.
How to auto scroll down in ListView control when update new item?
I have tried
listView1.Focus();
listView1.Items[listView1.Items.Count - 1].Selected = true;
but this not working.
Try
listView1.Items[listView1.Items.Count - 1].EnsureVisible();
EnsureVisible
did not work for me because ListView control was in an other tab. So i used this instead: listview1.TopItem = listView1.Items[listView1.Items.Count - 1]
–
Siegbahn Another possible solution:
listview1.TopItem = listView1.Items[listView1.Items.Count - 1];
old fashioned solution:
ListView1.SetFocus;
PostMessage(ListView1.Handle, WM_KEYDOWN, VK_DOWN, 0);
where x is an int, of the item in the list you want to see
listView1.Items[x].Focus();
listView1.Items[x].Selected = true;
listView1.EnsureVisible(x);
maybe
listView1.Items[listView1.Items.Count - 1].Selected = false;
listView1.Items[listView1.Items.Count - 1].Selected = true;
Codesleuth's answer of calling EnsureVisible() on the last item in the list only worked for me when called during the forms OnShown() event.
I tried doing it in the constructor, where I was populating my ListView, but nothing happened. Doing it during OnShown() worked a treat, however.
Hope this helps.
© 2022 - 2024 — McMap. All rights reserved.