我的头大了。。。。。。。。。。。。。。
我用LISTBOX和两个按扭,想用按扭使LISTBOX的ITEM上下移动一位,但是不能连续移动两下,就是说,移动一下可以,但是再按一下按扭就不行了,弹出“LIST INDEX OUT OF BOUNDS(-1),怎么搞的? 问题点数:50、回复次数:3Top
1 楼Wingsun(孙春阳)回复于 2001-01-18 09:46:00 得分 30
你在移动之后应该做给ListBox的ItemIndex属性赋值,这样就不会出错了,下面是一段BCB的代码
同样是将一个ListBox中的Item上移一位
if(lstAccounts->ItemIndex>0)
{
AnsiString tempstr;
tempstr=lstAccounts->Items->Strings[lstAccounts->ItemIndex];
lstAccounts->Items->Strings[lstAccounts->ItemIndex]=lstAccounts->Items->Strings[lstAccounts->ItemIndex-1];
lstAccounts->Items->Strings[lstAccounts->ItemIndex-1]=tempstr;
lstAccounts->ItemIndex=lstAccounts->ItemIndex-1;
}
Top
2 楼lwm8246(lwm8246)回复于 2001-01-18 09:58:00 得分 10
var i:integer;
i:=listbox.itemindex;
if (i>=0) and (i<=listbox.items.count-1) then move else don't moveTop
3 楼lwm8246(lwm8246)回复于 2001-01-18 10:01:00 得分 10
更正
var i:integer;
i:=listbox.itemindex;
//前移;
if (i=0) THEN don't move
//后移:
if i=listbox.items.count-1 then don't moveTop




