如题

解决方案 »

  1.   

    是不是选指定的选项...可以啊,你不用Ctrl,用Alt..不过这样等于没变,如果只用单击,那想要单击另外一个时,不就变成多选呢,所以用一个键控制选间断选项就好了..
      

  2.   

    我的意思是不按ctrl,shift键实现多选,
    有用户觉得ctrl,shift多选麻烦,想只用鼠标来多选,点一个选中一个。
      

  3.   

    没看懂什么意思 你把MultiSelect设为True,按着鼠标一拖不就多选了吗?如果不想按Ctrl键按Shift键也可以多选的。^_^
      

  4.   

    把MultiSelect设为True,按着鼠标一拖不就多选了吗?
      

  5.   

    MultiSelect 设置为True
    界面上放个TApplicationEvents 控件var
        pt:TPoint;procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
      var Handled: Boolean);
    var
        index:integer;
    begin
        if Msg.message=WM_LBUTTONDOWN then
        begin
            if Msg.hwnd=ListBox1.Handle then
            begin
                index:=ListBox1.ItemAtPos(pt,true);
                if index>=0 then
                    ListBox1.Selected[index]:=not ListBox1.Selected[index];
                Handled:=true;
            end;
        end;
    end;procedure TForm1.ListBox1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    begin
        pt.X:=X;
        pt.Y:=Y;
    end;procedure TForm1.BitBtn1Click(Sender: TObject);
    var
        i:integer;
    begin
        for i:=0 to ListBox1.Items.Count-1 do
            if ListBox1.Selected[i] then
                Memo1.Lines.Add(ListBox1.Items[i])
    end;
      

  6.   

    模拟按下了Ctrl键
    procedure TForm1.ListBox1Enter(Sender: TObject);
    begin
      keybd_event(17,0,0,0);
    end;procedure TForm1.ListBox1Exit(Sender: TObject);
    begin
      keybd_event(17,0,2,0);
    end;
      

  7.   

    感谢各位的解答^_^ 
    liangqingzhi使用模拟Ctrl键虽然好用,但有时容易锁住Ctrl键.
    gzmhero 的方法不错,但无法连续选择,我稍修改了一下:type
      TMousePos = record
        XPos, YPos: Smallint;
      end;
    var
      Index:Integer = -1;
      LastIndex: Integer;
    procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
      var Handled: Boolean);
    var
      I, I0, I1: Integer;
    begin
        if Msg.message=WM_LBUTTONDOWN then
        begin
            if Msg.hwnd=ListBox1.Handle then
            begin
              with TMousePos(Msg.lParam) do
                Index:=ListBox1.ItemAtPos(Point(XPos, YPos),true);
              LastIndex := Index;
              ListBox1.ItemIndex := LastIndex;
              if Index >= 0 then
                 ListBox1.Selected[Index]:=not ListBox1.Selected[Index];
              Handled := True;
            end;
        end;
        if Msg.message=WM_LBUTTONUP then
        begin
            if Msg.hwnd=ListBox1.Handle then
            begin
              Index := -1;
            end;
        end;
        if Msg.message=WM_MOUSEMOVE then
        begin
          if Msg.hwnd=ListBox1.Handle then
          begin
            if Msg.wParam and MK_LBUTTON <> 0 then begin;
              with TMousePos(Msg.lParam) do
                I1 := ListBox1.ItemAtPos(Point(XPos, YPos), True);
              if I1 = LastIndex then Exit;
              if I1 < 0 then Exit;
              LastIndex := I1;
              if I1 > Index then I0 := Index + 1 else begin
                I0 := I1;
                I1 := Index - 1;
              end;
              for I := I0 to I1 do
                ListBox1.Selected[I] := ListBox1.Selected[Index];
              ListBox1.ItemIndex := LastIndex;
            end;
          end;
        end;
    end;