zoukankan      html  css  js  c++  java
  • 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;

      

  • 相关阅读:
    kafka那些事儿
    netty
    kafka为什么吞吐量高,怎样保证高可用
    通用mybatis单表操作接口
    P1058立体图
    P2258 子矩阵
    P1439 【模板】最长公共子序列(LCS)
    洛谷P2672 推销员
    P3373线段树2
    P5018 对称二叉树
  • 原文地址:https://www.cnblogs.com/solokey/p/2113330.html
Copyright © 2011-2022 走看看