允许多选的ListBox需要加判断.可以参考被注释掉的代码.不再赘述.

 1 //OnMouseUp:
2
3 var
4 APoint: TPoint;
5 Index: Integer;
6 begin
7 if Button=mbRight then
8 begin
9 APoint.x := X;
10 APoint.y := Y;
11 Index := ListBox.ItemAtPos(APoint, True);
12 {if (ListBox.SelCount <= 1) and (Index >= 0) then begin
13 SelectedListBox(False);
14 LMDListBox.Selected[Index] := True;
15 end;}
16 {if (LMDListBox.SelCount > 0) and (Index >= 0) and LMDListBox.Selected[Index] then
17 begin
18 ListBox.ItemIndex:=Index;}
19 GetCursorPos(APoint);
20 { InitPopupMenu(Index,PopupMenu);}//根据选中的Item对PopupMenu的MenuItem进行调整.可选
21 PopupMenu.Popup(APoint.x,APoint.y);
22 { end;}
23 end;
24 end;

  SelectListBox代码:

1 var
2 i: Integer;
3 begin
4 for i:= 0 to ListBox.Items.Count - 1 do begin
5 ListBox.Selected[i] := Selected;
6 end;
7 end;

  

posted on 2011-07-21 22:39  solokey  阅读(821)  评论(0编辑  收藏  举报