查看: 1026|回复: 12
|
请问要怎样unselected listbox里的item
[复制链接]
|
|
如果我已经selected了listbox其中一个的item,而之后我要自动的unselected那个item,请问要怎么做的。。我用clearselected,但是它会unselected全部的item。
请允许我使用英文
if i click select an item in a listbox,after that i want it auto unselected,how should i perform this action.i use clearselected method is clear all the item that i selected for.i just want to unselected certain item. |
|
|
|
|
|
|
|
发表于 3-8-2006 11:49 AM
|
显示全部楼层
原帖由 fannwong 于 3-8-2006 11:30 AM 发表
如果我已经selected了listbox其中一个的item,而之后我要自动的unselected那个item,请问要怎么做的。。我用clearselected,但是它会unselected全部的item。
请允许我使用英文
if i click select an item in a ...
你是说一CLICK了ITEM就UNSELECT??
还是几时UNSELECT?? |
|
|
|
|
|
|
|
发表于 3-8-2006 12:13 PM
|
显示全部楼层
原帖由 fannwong 于 3-8-2006 11:30 AM 发表
如果我已经selected了listbox其中一个的item,而之后我要自动的unselected那个item,请问要怎么做的。。我用clearselected,但是它会unselected全部的item。
请允许我使用英文
if i click select an item in a ...
auto unselect 当然可以办得到, 问题在于, 你要 auto-unselect 的先决条件是什么? |
|
|
|
|
|
|
|

楼主 |
发表于 3-8-2006 02:01 PM
|
显示全部楼层
原帖由 goatstudio 于 3-8-2006 12:13 PM 发表
auto unselect 当然可以办得到, 问题在于, 你要 auto-unselect 的先决条件是什么?
就是说我的listbox里有8个item,user只能够click and select from item 1 to item 4,如果user click and select item 5,那么item 5 将auto unselect。。 |
|
|
|
|
|
|
|
发表于 3-8-2006 02:17 PM
|
显示全部楼层
原帖由 fannwong 于 3-8-2006 02:01 PM 发表
就是说我的listbox里有8个item,user只能够click and select from item 1 to item 4,如果user click and select item 5,那么item 5 将auto unselect。。
是不是说, 一次只可以选 4 个? 超过的话就不能在继续 select? |
|
|
|
|
|
|
|

楼主 |
发表于 3-8-2006 02:19 PM
|
显示全部楼层
原帖由 goatstudio 于 3-8-2006 02:17 PM 发表
是不是说, 一次只可以选 4 个? 超过的话就不能在继续 select?
对,我和我朋友都服了你。知道你大概什么问题都能回答。。请问我该,怎么coding。
my listbox selectionmode is multiplesimple
是不是用setselected(5,false)
[ 本帖最后由 fannwong 于 3-8-2006 03:34 PM 编辑 ] |
|
|
|
|
|
|
|
发表于 4-8-2006 12:09 AM
|
显示全部楼层
原帖由 fannwong 于 3-8-2006 02:19 PM 发表
对,我和我朋友都服了你。知道你大概什么问题都能回答。。请问我该,怎么coding。
my listbox selectionmode is multiplesimple
是不是用setselected(5,false)
过奖了. 
你的情况不能这样解决... 只能在 submit 的时候探测到超过 4 个被选择, 然后 prompt 用户. 那是因为用户可以按着滑鼠不放直接选择五六个... 或更多, 这个时候, 我们根本不会知道倒底要 unselect 那里一个. |
|
|
|
|
|
|
|

楼主 |
发表于 4-8-2006 08:22 AM
|
显示全部楼层
其实是这样。user不能select的parameter id不能大过4。如果user select parameter ID 5,system会出msgbox,然后不要highlight..因为当我们click the item in the listbox,the item will be highlighted....if user select paramter id 5,the item paramter id 5 should be no highlighted..how should i do |
|
|
|
|
|
|
|
发表于 4-8-2006 09:58 AM
|
显示全部楼层
试试看... 只有在你把滑鼠转移 focus 才会发生.
<script language="javascript">
function CheckDropDown (obj) {
for (var x = 0; x < obj.options.length; x++)
obj.options[x].selected = (obj.options[x].value > 4 && obj.options[x].selected)?false:obj.options[x].selected;
}
</script>
<select name="select" size="10" multiple onBlur="CheckDropDown(this);">
<option value="1">Item 1</option>
<option value="2">Item 2</option>
<option value="3">Item 3</option>
<option value="4">Item 4</option>
<option value="5">Item 5</option>
<option value="6">Item 6</option>
<option value="7">Item 7</option>
<option value="8">Item 8</option>
</select> |
|
|
|
|
|
|
|

楼主 |
发表于 4-8-2006 10:10 AM
|
显示全部楼层
原帖由 goatstudio 于 4-8-2006 09:58 AM 发表
试试看... 只有在你把滑鼠转移 focus 才会发生.
<script language="javascript">
function CheckDropDown (obj) {
for (var x = 0; x < obj.options.length; x++)
obj.op ...
忘记告诉您,我的是windows application,不时asp.net。。。或者我想到的另一个方法是,disable the item which greater than 4 in the listbox.。。想请问您,listbox里的item可以选择性的disable吗??
for example,i have a listbox with 5 items, how can I disable the third item only, in order to make it unselectable?
[ 本帖最后由 fannwong 于 4-8-2006 10:12 AM 编辑 ] |
|
|
|
|
|
|
|
发表于 4-8-2006 10:31 AM
|
显示全部楼层
原帖由 fannwong 于 4-8-2006 10:10 AM 发表
忘记告诉您,我的是windows application,不时asp.net。。。或者我想到的另一个方法是,disable the item which greater than 4 in the listbox.。。想请问您,listbox里的item可以选择性的disable吗??
for ...
:@ vb.net 还是 vb6? |
|
|
|
|
|
|
|
发表于 4-8-2006 10:43 AM
|
显示全部楼层
原帖由 goatstudio 于 4-8-2006 10:31 AM 发表
:@ vb.net 还是 vb6?
他会说是“window application”,那么可能就是vb.net了。。。不过,也有可能是C# |
|
|
|
|
|
|
|

楼主 |
发表于 4-8-2006 10:48 AM
|
显示全部楼层
我已经解决了。谢谢。。其实我犯了一个很苯的错误。我的listbox里的item没有sorting ascending,所以造成setselected(findid,false)有error。
Dim primaryColumn(0) As DataColumn
primaryColumn(0) = listsourceTable.Columns(parameterLanguage)
listsourceTable.PrimaryKey = primaryColumn
For Each itemstring As String In lstImprovingList.SelectedItems
FindID = listsourceTable.Rows.Find(itemstring.ToString)("ParameterID")
If FindID > 4 Then
'MsgBox(FindID)
lstImprovingList.SetSelected(FindID - 1, False)
MsgBox("Sorry,this paramater is not available for trial version.You only can select from paramter 1 to parameter 4.", MsgBoxStyle.Information, "Matrix+")
Exit For
End If
Next |
|
|
|
|
|
|
| |
本周最热论坛帖子
|