Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2005 Nov : Remove TProgressbar from TListView

www.cryer.info
Managed Newsgroup Archive

Remove TProgressbar from TListView

Subject:Remove TProgressbar from TListView
Posted by:"Codeman II" (thegentlem..@webmail.co.za)
Date:Tue, 15 Nov 2005 19:53:18 +0200

Hi there,

I have added a Progressbar in a ListView using Delphi 7.
The following is the code and it is working perfectly:

code begin
_______________________________________________________

procedure TForm1.Button1Click(Sender: TObject);
var
  r: TRect;
  pb: TProgressBar;
begin
  Listview1.Columns.Add.Width := 100;
  Listview1.Columns.Add.Width := 200;
  Listview1.ViewStyle         := vsReport;
  Listview1.Items.Add.Caption := 'Text';

  r := Listview1.Items[0].DisplayRect(drBounds);
  r.Left  := r.Left + Listview1.columns[0].Width;
  r.Right := r.Left + Listview1.columns[1].Width;

  pb := TProgressBar.Create(Self);
  pb.Parent := Listview1;
  pb.BoundsRect := r;
  pb.Position := 30;
  Listview1.Items[0].Data := pb;
end;


// Change the ProgressBar Position
// ProgressBar Position ändern

procedure TForm1.Button2Click(Sender: TObject);
var
  pb: TProgressBar;
begin
  pb := TProgressBar(Listview1.Items[0].Data);
  pb.StepIt;
end;

_______________________________________________________
code end

The question though is when I delete a item from the listview then how do I
remove the progressbar because
when I do something like this:

ListView.DeleteSelected;

the progressbar still exist although the selected items have been deleted.

Thanks for the help.

Info

Glossary

Replies:

www.cryer.info
Managed Newsgroup Archive