如何从 Delphi 10 中的 ListView 访问 ItemAppearance?
How to access an ItemAppearance from ListView in Delphi 10?
如下图所示,单击 ListView 中的项目时,我需要 select txtID
字段的值。我该怎么做?
procedure TForm1.ListView1ItemClick(const Sender: TObject;
const AItem: TListViewItem);
begin
showmessage(AItem.Objects[1].Data.AsString); // Value of field
showmessage(AItem.Objects[1].Name); // Name of field
// OR
showmessage(AItem.Data['txtID'].AsString); // Value of field
end;
{$R *.fmx}
procedure Form1.ListView1Change(Sender: TObject);
begin
if ListView1.Selected <> nil
then Label2.Text := TAppearanceListViewItem(ListView1.Selected).Objects.FindObjectT<TListItemText>('txtID').Text
else Label2.Text := '-';
//If you change the selected item with keyboard (up, down, left, right), then you will get back the selected value, without clicking on it.
end;
如下图所示,单击 ListView 中的项目时,我需要 select txtID
字段的值。我该怎么做?
procedure TForm1.ListView1ItemClick(const Sender: TObject;
const AItem: TListViewItem);
begin
showmessage(AItem.Objects[1].Data.AsString); // Value of field
showmessage(AItem.Objects[1].Name); // Name of field
// OR
showmessage(AItem.Data['txtID'].AsString); // Value of field
end;
{$R *.fmx}
procedure Form1.ListView1Change(Sender: TObject);
begin
if ListView1.Selected <> nil
then Label2.Text := TAppearanceListViewItem(ListView1.Selected).Objects.FindObjectT<TListItemText>('txtID').Text
else Label2.Text := '-';
//If you change the selected item with keyboard (up, down, left, right), then you will get back the selected value, without clicking on it.
end;