Geekpedia Tutorials Home

Building a C# Chat Client and Server

Building a C# Chat Client and ServerA step by step tutorial teaching you how to create your own chat client and chat server easily in C#, for local networks or the Internet.

in C# Programming Tutorials

Getting Hard Drive Information

Getting Hard Drive InformationA C# tutorial showing you how to make use of WMI to extract information on disk drives, such as model, capacity, sectors and serial number.

in C# Programming Tutorials

UPS Shipping Calculator

UPS Shipping CalculatorThis tutorial will teach you how to calculate the shipping cost based on the weight, height, length and depth of the box, the distance and the UPS service type.

in PHP Programming Tutorials

Create Your Own Rich Text Editor

Create Your Own Rich Text EditorCreating a Rich Text Editor using JavaScript is easier to do than you might think, thanks to the support of modern browsers; this tutorial will walk you through it.

in JavaScript Programming Tutorials
Search
Tutorials
Programming Tutorials
IT Jobs
From CareerBuilder

Using EnsureVisible() to scroll down to the bottom of a ListView

On Tuesday, October 18th 2005 at 04:41 PM
By Andrew Pociu (View Profile)
*****   (Rated 5 with 7 votes)
Advertisement
More C# Resources
You can easily programatically scroll to the bottom of a ListView using the EnsureVisible() method. This method takes 1 parameter - the index of the ListViewItem that you want to ensure visibility for. The trick to keep the ListView scrolled down is to use the EnsureVisible() method every time a new item is added to the list, and pass that item's index as a parameter. So by passing the parameter of the last item in the list view to this method, the ListView always stays scrolled down to the bottom:

myListView.EnsureVisible(lstMonitor.Items.Count - 1);

This is one way, however if you're planning to scroll down every time a new item is added to the list, you can use a method which has the same name - EnsureVisible() - but this time it belongs to ListViewItem rather than ListView:

myListViewItem.EnsureVisible();

In this case you don't need to pass any parameters because it automatically scrolls to the specified ListViewItem.
Digg Digg It!     Del.icio.us Del.icio.us     Reddit Reddit     StumbleUpon StumbleIt     Newsvine Newsvine     Furl Furl     BlinkList BlinkList

Rate Rate this Knowledge Base article
Comment Current Comments
by doris on Monday, May 1st 2006 at 01:20 AM

genius!!!

by bryan on Friday, June 23rd 2006 at 01:23 PM

PERFECT!

by Juergen on Monday, September 4th 2006 at 11:49 AM

Perfect!
Works also on .net cf2.

by saeid rasouli on Tuesday, September 19th 2006 at 03:49 AM

So thanks
I googled for hours and i found not.
You helped me so much.
I remember this site forever.

by Avalon Avenger on Saturday, September 30th 2006 at 01:31 AM

Good info!

This can also be done through an alternative method found here:

http://xamlxaml.com/2006/09/16/scrolling-through-a-listview-programatically-with-scrollintoview/

by Mug on Monday, January 8th 2007 at 12:49 PM

Great !!
This site rocks!!

by Philip H on Friday, March 2nd 2007 at 09:25 AM

FYI: ListViewItem.EnsureVisible() is not available in .Net CF2

by Thabo on Thursday, July 5th 2007 at 11:53 PM

Thanx, the problem is i think my CTP version doesnt have a EnsureVisible() method, but i found an alternative. I used BringIntoView() method.

by rizwan on Thursday, April 17th 2008 at 05:33 AM

thanks man

by Elmer on Wednesday, November 12th 2008 at 03:16 AM

Cool ... it works fine to me

tnx

by Dan on Thursday, November 27th 2008 at 09:27 AM

Thanks! Such a simple answer but I could have spent hours looking for it.

by Nick on Tuesday, February 10th 2009 at 07:32 PM

This method can not be called in the constructor or while the form is being loaded. At the very least it has to be called in the Form.Shown event.

by Aishah Mohammad on Tuesday, April 13th 2010 at 05:25 AM

Thanks a gazallion..its work perfect..im happy..thanks dear for sharing!

by Demolisher on Friday, April 16th 2010 at 11:43 AM

Thanks, i really happy

by Ikpil on Tuesday, May 4th 2010 at 02:32 AM

You are the kindest a person.
Thanks.!!!!

by jyoti on Wednesday, November 17th 2010 at 01:04 AM

hi,
i am having list of checkbox controls in list view noe i want to visible the last control in listview how can i do it.? ensurevisible is not working in this case

by baddz_aiza on Wednesday, July 20th 2011 at 05:27 AM

thanks a lot..it really helps.

by apply for credit cards on Sunday, December 18th 2011 at 12:32 PM

i liked it too much . better if u provide a program and give comments on it .such as a bank account program. Why don't you post your own solution Pavlo..... it would have sure taken less time than writing all that.

by Rohit Singh on Wednesday, December 21st 2011 at 11:41 PM

Great.....

It works. i had searched google but it was awesome
Can i get a smooth scroll on listview

Thanks..

by Rohit Singh on Wednesday, December 21st 2011 at 11:41 PM

Great.....

It works. i had searched google but it was awesome
Can i get a smooth scroll on listview

Thanks..

by PetersDixie33 on Saturday, December 31st 2011 at 06:18 AM

That's great that we are able to take the <a href="http://goodfinance-blog.com/topics/personal-loans">personal loans</a> moreover, that opens up new chances.

by F on Tuesday, December 11th 2012 at 02:47 AM

Excellent! Thanks...


Comment Comment on this Knowledge Base article
Name: Email:
Message:
Knowledge Base Related Knowledge Base Articles
There are no related KB articles.

Comment Related Source Code
There is no related code.

Comment Related Tutorials
There are no related tutorials.

Jobs C# Job Search
My skills include:

Enter a City:

Select a State:


Advanced Search >>
Ads

From the creators of Geekpedia, a revolutionary new coupon website!

BargainEZ has coupons codes, printable coupons, bargains and it is the leading source of Passbook coupons for iPhone and iPod touch devices.

Coupons
Discover Geekpedia
Other Resources