Ismail Gunes
Ismail Gunes

Reputation: 558

FocusedItem Index and SelectedIndex

I'm using c# 2008 on 3.5 .NET platform

When I use:

int index = Listview1.SelectedIndex;

I'm getting:

"Error 1 'System.Windows.Forms.ListView' does not contain a definition for 'SelectedIndex' and no extension method 'SelectedIndex' accepting a first argument of type 'System.Windows.Forms.ListView' could be found (are you missing a using directive or an assembly reference?)"

But If I use:

int index = Listview1.FocusedItem.Index;

It works. Is there any compatibility problem of SelectedIndex in c# 2008 or .NET 3.5?

Upvotes: 1

Views: 171

Answers (1)

Owen Pauling
Owen Pauling

Reputation: 11841

System.Windows.Forms.ListView does not have a property SelectedIndex. However, System.Web.UI.WebControls.ListView does. It looks like you're referencing the wrong class.

If you really do need System.Windows.Forms.ListView then there is a property SelectedIndices

Upvotes: 1

Related Questions