以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  请教SelectedIndex 转为字符的问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=11897)

--  作者:yangming
--  发布时间:2011/8/16 10:12:00
--  请教SelectedIndex 转为字符的问题

If e.Form.Controls("ListBox1").SelectedIndex >= 0 Then
e.Form.Controls("ListBox2").Items.Add(e.Form.Controls("ListBox1").SelectedIndex.ToString)
e.Form.Controls("ListBox1").Items.Remove(e.Form.Controls("ListBox1").SelectedIndex.ToString)
Else
MessageBox.Show("请选择一行数据!", "错误", MessageBoxButtons.ok, MessageBoxIcon.Warning)
End If

这是一个按钮代码,目的是将A列表框中选择的一行字符转移到B列表框中,并删除A列表框中的字符,现在出现两个问题。

1。红色的部分没有生效,在B列表框中出现的是数字,也就是所选的行的位置

2。紫色部分没有执行,也就是说“Remove”没起作用

请教如何解决?


--  作者:狐狸爸爸
--  发布时间:2011/8/16 10:40:00
--  
If e.Form.Controls("ListBox1").SelectedIndex >= 0 Then
    e.Form.Controls("ListBox2").Items.Add(e.Form.Controls("ListBox1").SelectedItem)
    e.Form.Controls("ListBox1").Items.Remove(e.Form.Controls("ListBox1").SelectedItem)
Else
    MessageBox.Show("请选择一行数据!", "错误", MessageBoxButtons.ok, MessageBoxIcon.Warning)
End If

--  作者:yangming
--  发布时间:2011/8/16 11:20:00
--  
谢谢,成功了,呵