列表项不起作用 [英] listitems not working
本文介绍了列表项不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个列表框.
将listitems从list1移到list2时,它会正常工作.
但是,当我将listitems从list2移到list1时,它不会在list1中更新.
我根据列表使用相同的代码.
这里的问题是什么...
看到我的代码
------------
Hi,
I have two listboxes.
When move listitems from list1 to list2, it will be working fine.
But, when i move listitems from list2 to list1, it will not update in the list1..
i am using the same code for both based on the list.
what is the problem over here...
see my code
------------
Protected Sub btnAddClick_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAddClick.Click
If lstTot.SelectedIndex > -1 Then
Dim _value As String = lstTot.SelectedItem.Value
Dim _text As String = lstTot.SelectedItem.Text
Dim item As New ListItem()
item.Text = _text
item.Value = _value
lstEx.Items.Add(item)
lstTot.Items.Remove(item)
End If
End Sub
Protected Sub btnRemClick_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRemClick.Click
If lstEx.SelectedIndex > -1 Then
Dim _value As String = lstEx.SelectedItem.Value
Dim _text As String = lstEx.SelectedItem.Text
Dim item As New ListItem()
item.Text = _text
item.Value = _value
lstEx.Items.Remove(item)
lstTot.Items.Add(item)
End If
End Sub
推荐答案
可能首先添加,然后删除
maybe first ADD and then Remove
这篇关于列表项不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文