Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Listview focus on row
Message
From
19/05/2005 13:08:19
 
 
To
19/05/2005 12:28:52
Steve Jones
Business Systems Services Uk Ltd
Swansea, United Kingdom
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01015871
Message ID:
01015896
Views:
20
Steve,

The only reason you're getting the IndexOutOfRange is that you're probably not checking the ListView's .SelectedIndices.Count property prior to processing anything in the SelectedIndexChanged event handler. So, try something like this:
private void oListView_SelectedIndexChanged(object sender, System.EventArgs e)
{
	if (this.oListView.SelectedIndices.Count > 0)
	{
		// whatever code you need.
	}
}
~~Bonnie



>Hi,
>
>How can you programmatically set the focus to a particular row in a listview? We are using listviews and if user clicks on part of listview where there is no row, it fails with IndexOutOfRange.
>
>What I want to do is catch this and set focus to last (or first) row in the listview.
>
>Thanks for any help
>
>Steve
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform