簡體   English   中英

如何在c#中禁用列表視圖的特定索引處的項目

[英]How to disable item at particular index of a listview in c#

在處理listview的項目后,我正在使用它刪除它

  lstSqlStatements.Items.RemoveAt(selected_index);

然而,這完全破壞了我的索引跟蹤,因為它正在從列表視圖中刪除項目。

有沒有辦法在列表視圖中禁用該項?(這樣用戶不會再次點擊它)

試過這個? 用谷歌搜索它。 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;
    }

這將隱藏UI中的第3行。

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;
        }
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM