[英]My Edit Button and Delete Button are conficting
在我对 select 列表视图和编辑按钮进行编码后,我尝试使用 VB.net 在列表视图中编辑我的记录,但在我对删除按钮进行编码后,它开始出错
这是我的编辑按钮
txtID.Text = CustomerList.SelectedItems(0).SubItems(0).Text
txtFN.Text = CustomerList.SelectedItems(0).SubItems(1).Text
txtLN.Text = CustomerList.SelectedItems(0).SubItems(2).Text
txtAdr.Text = CustomerList.SelectedItems(0).SubItems(3).Text
cbOrder.Text = CustomerList.SelectedItems(0).SubItems(4).Text
cbPaymen.Text = CustomerList.SelectedItems(0).SubItems(5).Text
DatePicker.Text = CustomerList.SelectedItems(0).SubItems(6).Text
End Sub
这是我的列表视图 Select 代码
Dim s = n1 + n2 + n4 + n8
br = ListBox1.SelectedItem.ToString()
CustomerList.SelectedItems(0).SubItems(1).Text = txtFN.Text
CustomerList.SelectedItems(0).SubItems(2).Text = txtLN.Text
CustomerList.SelectedItems(0).SubItems(3).Text = txtAdr.Text
CustomerList.SelectedItems(0).SubItems(4).Text = cbOrder.Text
CustomerList.SelectedItems(0).SubItems(5).Text = cbPaymen.Text
CustomerList.SelectedItems(0).SubItems(6).Text = DatePicker.Text
CustomerList.SelectedItems(0).SubItems(7).Text = i
CustomerList.SelectedItems(0).SubItems(8).Text = br
CustomerList.SelectedItems(0).SubItems(9).Text = s
End Sub
这是我的删除按钮代码
CustomerList.Items.Remove(CustomerList.SelectedItems(0))
我得到一个错误:
ArgumentOutofRangeException 未处理
当我删除列表视图 select 代码时,两个按钮都可以正常工作
请帮忙
删除选定的 ListView 项目获取选定项目的索引然后使用该索引来标识要删除的项目。
Private Sub RemoveListViewItem()
Dim myIndex As Integer = CustomerList.SelectedIndices(0)
CustomerList.Items(myIndex).Remove()
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.