VB.net listview 如何插入一行
答案:1 悬赏:60 手机版
解决时间 2021-04-04 14:17
- 提问者网友:未信
- 2021-04-03 17:02
VB.net listview 如何插入一行
最佳答案
- 五星知识达人网友:鱼忧
- 2021-04-03 18:11
也不是很熟悉,将就用吧。
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
With ListView1
.Columns.Add("姓名")
.Columns.Add("年龄")
.Columns.Add("姓别")
End With
End Sub
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Static Index As Integer
Index += 1
If ListView1.SelectedIndices.Count > 0 Then '如果有选中则插入
Dim lItem As System.Windows.Forms.ListViewItem = ListView1.Items.Insert(ListView1.SelectedIndices.Item(0) + 1, "李丫" & Index)
lItem.SubItems.AddRange(Split("24,女", ","))
Else '否则添加
Dim lItem As System.Windows.Forms.ListViewItem = ListView1.Items.Add("李丫" & Index)
lItem.SubItems.AddRange(Split("24,女", ","))
End If
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
With ListView1
.Columns.Add("姓名")
.Columns.Add("年龄")
.Columns.Add("姓别")
End With
End Sub
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Static Index As Integer
Index += 1
If ListView1.SelectedIndices.Count > 0 Then '如果有选中则插入
Dim lItem As System.Windows.Forms.ListViewItem = ListView1.Items.Insert(ListView1.SelectedIndices.Item(0) + 1, "李丫" & Index)
lItem.SubItems.AddRange(Split("24,女", ","))
Else '否则添加
Dim lItem As System.Windows.Forms.ListViewItem = ListView1.Items.Add("李丫" & Index)
lItem.SubItems.AddRange(Split("24,女", ","))
End If
End Sub
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯