tags:

views:

87

answers:

1

Hi All,

I am creating a listbox with itemsource of type dataview. I want to scroll the listbox to praticular item which is not selected. I am using the following code for selected item.

Code:

Binding listbox:

DataView dv = newDt.DefaultView;
            dv.Sort = "Count Desc";
            lbResult.DataContext = dv;

To get the row based on id:

 var selectResult = from mypro in albumDetails.ToTable().AsEnumerable() where mypro.Field<string>("ID")==search.ID  select mypro;

            if (lbResult.SelectedItem != null)
            {
                lbResult.ScrollIntoView(**lbResult.Items[0]**);
            }

How to get the index if the row in the list box.

Geetha

A: 

I don't know what is the albumDetails object. Here is the code to get index from DataView.

 DataRow row = dataview.Select("ID='" + search.ID + "'")[0];
 int i= dataview.Rows.IndexOf(row); 
Ragunathan
ho no still im getting -1 index
Geetha
are you getting proper row value? What is the albumDetails object?
Ragunathan
i am getting row value.
Geetha
Ragunathan