删除listview控件中的单行或多行。 [英] Deleting single or multiple row in a listview control.

查看:138
本文介绍了删除listview控件中的单行或多行。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,我是NanaKwame。

我想使用删除按钮从listview控件中删除单行或多行。如果我选择第一行能够从列表视图中删除所选行,但如果我选择第二行或除第一行之外的任何其他行不能删除所选行但是删除第一行是第一行listview控件中的索引号为零(0)。



Listview是我使用的li stview控件的名称。 />
任何帮助对我都有很大帮助。在此先感谢。

以下是我使用的代码。



Hi friends, am NanaKwame.
Please I want to delete a single row or multiple rows from a listview control using a delete button. If I select the first row is able to delete the selected row from the listview, but if I select second row or any other row apart from the first row is not able to delete the selected row but rather delete the first row that is the first index number which is zero(0) in the listview control.

Listview is the name of the listview control I used.
Any assistance will be of great help to me. Thanks in advance.
Below is the code I used.

Dim x As Integer
       For x = 0 To ListView.SelectedIndices.Count - 1
           Me.ListView.Items.RemoveAt(x)
       Next

推荐答案

你可能正在寻找这个。



You Might be looking for this.

For Each x As Windows.Forms.ListViewItem In ListView1.Items
    If x.Selected Then
        x.Remove()

    End If
Next


这篇关于删除listview控件中的单行或多行。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆