TTMSFNCListEditor.OnItemCanDelete Event
Fires to allow the application to prevent deletion of a specific chip.
API unit family: TMSFNCListEditor
Declaring type: TTMSFNCListEditor
Inherited from: TTMSFNCCustomListEditor
Syntax
OnItemCanDelete: TTMSFNCCustomListEditorItemCanDelete;
__property TTMSFNCCustomListEditorItemCanDelete OnItemCanDelete = {read=FOnItemCanDelete, write=FOnItemCanDelete};
Usage examples
Validate item edits
Prevents required items from being deleted and trims edited text.
procedure TForm1.ConfigureListEditorEvents;
begin
TMSFNCListEditor1.OnItemCanDelete := TMSFNCListEditor1ItemCanDelete;
TMSFNCListEditor1.OnItemUpdate := TMSFNCListEditor1ItemUpdate;
end;
procedure TForm1.TMSFNCListEditor1ItemCanDelete(Sender: TObject;
AItemIndex: Integer; var ACanDelete: Boolean);
begin
ACanDelete := TMSFNCListEditor1.Items[AItemIndex].Value <> 'required';
end;
procedure TForm1.TMSFNCListEditor1ItemUpdate(Sender: TObject;
AItemIndex: Integer; var AText: string);
begin
AText := Trim(AText);
end;
void __fastcall TForm1::ConfigureListEditorEvents()
{
TMSFNCListEditor1->OnItemCanDelete = TMSFNCListEditor1ItemCanDelete;
TMSFNCListEditor1->OnItemUpdate = TMSFNCListEditor1ItemUpdate;
}
void __fastcall TForm1::TMSFNCListEditor1ItemCanDelete(TObject *Sender,
int AItemIndex, bool &ACanDelete)
{
ACanDelete = TMSFNCListEditor1->Items->Items[AItemIndex]->Value != "required";
}
void __fastcall TForm1::TMSFNCListEditor1ItemUpdate(TObject *Sender,
int AItemIndex, System::UnicodeString &AText)
{
AText = Trim(AText);
}