Dana Yeger Dana Yeger - 1 year ago 117
C# Question

List box update with focus on the last line in the listbox

in my application i am add all my new item to my list box, the speed is very fast and i want the list box show me the last item all the time ongoing, i mean that the focus in the list box will be in the last line all the time, how can i do it ?

in this function i am update my list box:

private void bgWSniffer_ProgressChanged(object sender, ProgressChangedEventArgs e)
tshark = e.UserState as Tshark;

Answer Source

After adding the item to the list box, add this line:

listBoxPacketsSnifferTab.SelectedIndex = listBoxPacketsSnifferTab.Items.Count - 1;

It will make the selected item the last. Keep in mind that the index is zero based.

Read more here:


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download