如何在C#中将列表框滚动到底部? ListBox中的项目没有名称,这可能会使其更加困难。
答案 0 :(得分:2)
你可以这样做..
listbox.ScrollIntoView(listbox.Items[listbox.Items.Count - 1]);
答案 1 :(得分:1)
在C#中:
yourListBox.SelectedIndex = yourListBox.ItemsSource.Count();
如果由于某种原因你没有Count
,请试试这个:
public static int Count<TSource>(this IEnumerable<TSource> source)
{
if (source == null)
throw new ArgumentNullException("source");
ICollection collection = source as ICollection;
if (collection != null)
return collection.Count;
int num = 0;
foreach (TSource item in source)
checked { ++num; }
return num;
}