ListBox类似组件,鼠标右键点击事件得到选中Item

允许多选的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;

  

转载于:https://www.cnblogs.com/solokey/archive/2011/07/21/2113330.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值