1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
procedure TForm1.Button1Click(Sender: TObject);
var
suppression:boolean;
begin
form1.TabItem1.Enabled:=true;
TabControl1.ActiveTab := TabItem1;
If ListBox1.ItemIndex<0 Then Exit;
If Liste.Items[ListBox1.ItemIndex]=Nil Then Exit;
suppression:=false;
{ MessageDlg('Confirmer suppression ?', TMsgDlgType.mtConfirmation, [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], 0,
procedure(const AResult: TModalResult)
begin
if AResult = mrYes then
suppression:=true;
end
);
}
TDialogservice.MessageDialog('voulez vous vraiment supprimer ?',
tmsgdlgtype.mtconfirmation, [tmsgdlgbtn.mbOk, tmsgdlgbtn.mbCancel],
tmsgdlgbtn.mbOk, 0,
procedure(const AResult: TModalResult)
begin
case AResult of
mrok:
suppression:=true;
mrcancel:
suppression:=false;
else
raise exception.Create('pas bon');
end;
end);
if suppression=true then begin
Dispose(Liste.Items[ListBox1.ItemIndex]);
// Suppression de l'élément
Liste.Delete(ListBox1.ItemIndex);
// Mise a jour du ListBox
recharge_ListBox;
end;
end; |
Partager