Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

stop losin selection on list items when enterin listview with mouse

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
may anyone give me a tip on SelectItem list event to prevent list items from being deselected when first mouse-clicking list view? The key idea is to get a folder explorer-like beheviour in my app so that list items remain selected until user clicks in the list view twice.
Thank you for your help.
 
Long winded but have a look at the following it may give you some ideas.

Code:
  public
    { Public declarations }
    changeIt : boolean;
    beforeEnter : TStringList;
  end;



var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.ListBox1Exit(Sender: TObject);
var
  loop : Integer;
begin
   changeIt := False;
   for loop:= 0 to (listBox1.Items.Count-1) do
   begin
      if listbox1.selected[loop] = True then
        beforeEnter.Insert(loop,'T')
      else
        beforeEnter.Insert(loop,'F')
   end;

end;

procedure TForm1.ListBox1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  loop : Integer;
begin
   if (beforeEnter.Count > 0) and (changeIt=false) then
   begin
      for loop:= 0 to beforeEnter.Count-1 do
      begin
         if beforeEnter.strings[loop] = 'T' then
           listBox1.ItemIndex  := loop
      end;
   end;
   changeIt := True;
end;


procedure TForm1.FormCreate(Sender: TObject);
begin
  beforeEnter := TStringList.Create;

end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
   beforeEnter.Free;
end;

END.

x-)
Billy H

bhogar@acxiom.co.uk
 
Ta Billy that code snippet was really helpful, you gotten me out da pit!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top