1

I am using a listview in my C# application. Generally if listview's scrollable property is enabled we will use following command to make it scroll down automatically when new line is added:

listview1.View = SmallIcon;
listView1.Items[listViewLog.Items.Count - 1].EnsureVisible();

When we want to disable (hide) listview's horizontal scrolling we totally disable its scrollable property and use following code to only define vertical scrolling:

[DllImport("user32.dll")]
static public extern bool ShowScrollBar(System.IntPtr hWnd, int wBar, bool bShow);
private const int SB_HORZ = 0x0;
private const int SB_VERT = 0x1;
private const int SB_BOTH = 0x3;

ShowScrollBar(this.listView1.Handle, (int)SB_VERT, true);

In this situation how can I make listview to scroll down automatically? listView1.Items[listViewLog.Items.Count - 1].EnsureVisible() is not useful in this case.

Thanks in advance for your help.

4

0 回答 0