0

guys after processing the item of a listview i was removing it using

  lstSqlStatements.Items.RemoveAt(selected_index);

However this was completely disrupting my index trace as it was removing the item fron the listview.

Is there any ways to just DISABLE the item in the listview ?(so that the user does not click again on it)

Anoushka Seechurn
  • 2,166
  • 7
  • 35
  • 52

2 Answers2

2

tried this? Just googled it. http://social.msdn.microsoft.com/Forums/vstudio/en-US/d3c68d8a-89d3-4de6-b9f9-4d617ffdeb77/disable-item-selection-of-the-listview

private void listView1_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) {
        if (e.IsSelected) e.Item.Selected = false;
    }
Loko
  • 6,539
  • 14
  • 50
  • 78
  • @AnoushkaSeechurn http://stackoverflow.com/questions/1425623/remove-the-selected-item-from-listview ? – Loko Sep 04 '13 at 07:23
  • I do not want to REMOVE IT, i just want to DISABLE it. can view it but cannot click on it(cannot select it). – Anoushka Seechurn Sep 04 '13 at 07:26
  • 1
    @AnoushkaSeechurn Sorry I read it wrong. http://stackoverflow.com/questions/5472172/how-do-you-disable-an-item-in-listview-control-in-net-3-5 ? – Loko Sep 04 '13 at 07:28
0

This will hide the 3rd row as in UI.

protected void ListView1_ItemDataBound(object sender, ListViewItemEventArgs e)
    {
        if (e.Item.ItemType == ListViewItemType.DataItem)
        {
            int index = e.Item.DisplayIndex;
            if(index==2)

            e.Item.Visible = false;
        }
    }
SamuraiJack
  • 5,131
  • 15
  • 89
  • 195