0

In the application that I am building I have a log window that contains a listview control. This listview control has two columns, a time stamp column and log description column. When an event happens it is added to the listview. The problem is that when about 15+ events happen they start being hidden since the control does not go that far. Is there a way to add an item to the listview control and then have the listview control scroll down to the bottom so that that entry is visible.

Thanks

2
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by b89smith
0

Your post title does not convey your problem.

Use ListView1.TopItem property

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim k As New ListViewItem(TextBox1.Text)
        k.SubItems.Add(TextBox2.Text)
        ListView1.Items.Add(k)
        ListView1.TopItem = k
    End Sub
0

topitem is a read only property, so it won't work. I found a better way to do it through using the following code

Dim k As New ListViewItem(TextBox1.Text)

k.SubItems.Add(TextBox2.Text)

ListView1.Items.Add(k)
ListView1.EnsureVisible(ListView1.Items.Count)
0

EnsureVisible is a right choice. TopItem property - I have tested this code with VS 2005 and VS 2008 - it is not a readonly.

Thanks

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.