在ListBox中获取多个选择 [英] Getting Multiple selection in ListBox
本文介绍了在ListBox中获取多个选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个像英语,日语,西班牙语这样的字符串。和一个列表框
包含10个lang。
现在我希望我的列表框应该是选定的值作为
字符串中的值其余的值将被取消选择。
但我得到的是最后选择的值(西班牙语在这个
的情况下)。
任何帮助.......
问候,
Amit
I have a string like "English,Japanese,Spanish" and a list box which
contains say 10 lang.
Now I want my List box should come by selected values as the values in
string and rest of the values to be unselected.
But what I am getting is the last value selected (Spanish in this
case).
Any help.......
Regards,
Amit
推荐答案
Amit,
遍历每个项目并检查每个项目是否都被选中。
For每个ListBoxItem如ListItem在MyListBox.Items中
如果ListBoxItem.Selected那么
''---这个项目被选中用它做点什么
结束如果
下一页
-
此致,
S. Justin Gengo,MCP
网站开发人员/程序员
www.aboutfortunate.com
" Out混乱来了。
Nietzsche
< ar ********* @ gmail.com>在消息中写道
news:11 ********************* @ p10g2000cwp.googlegro ups.com ...
Amit,
Loop through each item and check if each one is selected.
For Each ListBoxItem As ListItem In MyListBox.Items
If ListBoxItem.Selected Then
''---This item is selected do something with it
End If
Next
--
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
<ar*********@gmail.com> wrote in message
news:11*********************@p10g2000cwp.googlegro ups.com...
我有一个像英语,日语,西班牙语这样的字符串。
包含10个lang的列表框。
现在我希望我的列表框应该是选定的值作为
字符串中的值以及要取消选择的其余值。
但我得到的是最后选择的值(西班牙语在这个案例中)。
任何帮助.......
问候,
Amit
I have a string like "English,Japanese,Spanish" and a list box which
contains say 10 lang.
Now I want my List box should come by selected values as the values in
string and rest of the values to be unselected.
But what I am getting is the last value selected (Spanish in this
case).
Any help.......
Regards,
Amit
char [] splitter = {'',''};
string
[] lang = ds.Tables [0] .Rows [0] [" USER_LANG_ID"]。ToString()。拆分(拆分器);
foreach(在lang中的字符串i)
{
for(int j = 0; j< lstLang.Rows; j ++)
{
if(lstLang.Items [j] .Text == i)
{
lstLang.SelectedIndex = j;
Response.Write(i);
}
}
}
这是我正在使用的代码...但它不起作用....
请看.....
char[] splitter = {'',''};
string
[]lang=ds.Tables[0].Rows[0]["USER_LANG_ID"].ToString().Split(splitter);
foreach(string i in lang)
{
for(int j=0;j<lstLang.Rows;j++)
{
if(lstLang.Items[j].Text==i)
{
lstLang.SelectedIndex=j;
Response.Write(i);
}
}
}
This is the code I am using... but it does not work....
Pls see.....
>
嗨Amit,
您是否更改了选择模式f从单一到多个??
Hi Amit,
Have you changed selection mode from single to multiple??
这篇关于在ListBox中获取多个选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文