How to scroll listview items programmatically

13,863

Despite @user3711357 correct answer, I spent too much time trying to understand why it is not working for me. I found that trying to call EnsureVisible in the constructor of the form will not work.

public class MyForm
{
    public MyForm()
    {
        InitializeComponent();
        listView1.EnsureVisible(8);  // will not work !!!
    }

    private void MyForm_Load(object sender, EventArgs e)
    {
        listView1.EnsureVisible(8);  // Works fine
    }
}
Share:
13,863
user3711357
Author by

user3711357

Updated on June 24, 2022

Comments

  • user3711357
    user3711357 almost 2 years

    I have a listview control on my WinForms application.

    here, on click of separate button, i do change couple of listview items backcolor and reload the whole grid as there are certain changes into database so, reloading from database on each click of button.

    Now, problem is, once the grid is reloaded then lastly added items are scrolled so, need to scroll all items and find so, it makes hard to end user.

    Is there any way to ,scroll the lastly added items or updated items into listview automatically (I mean, programmatically so, it could be view to user directly without being manually scrolled).