Jump to content
toufik

TControlList delete an item

Recommended Posts

I'm new to using  component TControlList  can someone help with this 
How exactly can a selected field or item from the TControlList can  be deleted?

i'm loding the items like this 
procedure TForm1.ControlList1BeforeDrawItem(AIndex: Integer; ACanvas: TCanvas;
  ARect: TRect; AState: TOwnerDrawState);
begin
dm.fdmedcin.RecNo := AIndex+1;
lbl5.Caption := 'Spc:' +TStringField( dm.fdmedcin.FieldByName('Spc_doc') ).AsString ;
.........

.........

........

procedure TDM.fdmedcinAfterOpen(DataSet: TDataSet);
begin
form1.ControlList1.ItemCount := fdmedcin.RecordCount;

 

Untitled.png

Share this post


Link to post

the answer is 
 

procedure TForm1.Delete;
begin
  dm.fdmedcin.RecNo := ControlList1.ItemIndex + 1; // seems like you add one in your OnBeforeDrawItem too
  dm.fdmedcin.Delete;
  ControlList1.ItemCount := fdmedcin.RecordCount;
end;

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×