ListView Controls - Geting the Selected Item

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When using a list view control I am trying to use the SelecteIndexChanged event. However, when this event is fired, I can get the index of the selected row. SelectedIndices.Count = 0. How can I get the new index?
 
public void listView_SelectedIndexChanged(object sender, System.EventArgs
e)
{
System.Windows.Forms.ListView listView = (System.Windows.Forms.ListView)
sender;
ListViewItem editItem = listView.FocusedItem;
if (editItem != null)
{
DataRow dset_Row = null;
if (listView == listView000)
{
if (editItem.Text != s_TableMainFrame00_ID) // This runs two times,
only do when there is a change.
{
s_TableMainFrame00_ID = editItem.Text;
i_MainFrame00ListSelected = editItem.Index;
drow_MainFrame00 = null;
for (int i=0;i<dtable_MainFrame00.Rows.Count;i++)
{
dset_Row = dtable_MainFrame00.Rows;
if (dset_Row[sa_MainFrame00Rows[0]].ToString() ==
s_TableMainFrame00_ID)
{
drow_MainFrame00 = dset_Row;
break;
}
} // for (int i=0;i<dtable_MainFrame00.Rows.Count;i++)
OnSetTextDialog(ref drow_MainFrame00);
i_MainFrame01SortCol = 2; // Build ListView and Sort by DatumS
i_MainFrame02SortCol = 3; // Build ListView and Sort by DatumW
}
}
progessBarMainFrame.Value = 0;
}
}

James said:
When using a list view control I am trying to use the SelecteIndexChanged
event. However, when this event is fired, I can get the index of the
selected row. SelectedIndices.Count = 0. How can I get the new index?
 
Back
Top