William23668 8 Posted December 19, 2022 (edited) Hi It is FMX app but I just want to test adding items from code in Windows so I used that code from here var LItem: TListItem; begin LItem := TListItem.Create(ListViewContacts.Items); LItem.Caption := 'new item'; I added "Commctrl" to uses clause but "Caption" is not defined, why ? Edited December 19, 2022 by William23668 Share this post Link to post
programmerdelphi2k 237 Posted December 19, 2022 in "FMX", all "caption" stay to "Text" -> Text = Caption! Share this post Link to post
William23668 8 Posted December 19, 2022 23 minutes ago, programmerdelphi2k said: in "FMX", all "caption" stay to "Text" -> Text = Caption! Undeclared identifier: 'Text' Share this post Link to post
programmerdelphi2k 237 Posted December 19, 2022 (edited) FMX.ListView.Types, FMX.ListView.Appearances, FMX.ListView.Adapters.Base, FMX.ListView; type TForm1 = class(TForm) ListView1: TListView; procedure FormCreate(Sender: TObject); ... implementation {$R *.fmx} procedure TForm1.FormCreate(Sender: TObject); var LVItem: TListViewItem; begin LVItem := ListView1.Items.Add; LVItem.Text := 'hello'; end; end. Edited December 19, 2022 by programmerdelphi2k Share this post Link to post
programmerdelphi2k 237 Posted December 19, 2022 (edited) Vcl.ComCtrls; type TForm1 = class(TForm) ListView1: TListView; procedure FormCreate(Sender: TObject); ... implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); var MyListItem: TListItem; // VCL begin MyListItem := ListView1.Items.Add; MyListItem.Caption := 'hello'; end; end. Edited December 19, 2022 by programmerdelphi2k Share this post Link to post
William23668 8 Posted December 20, 2022 (edited) interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, System.Permissions, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, Vcl.ComCtrls, Commctrl, FMX.AddressBook.Types, FMX.AddressBook, FMX.StdCtrls, FMX.SearchBox, FMX.Layouts, FMX.ListBox, FMX.Controls.Presentation, FMX.Edit, FMX.TabControl, FMX.Platform, System.Actions, FMX.ActnList, FMX.ListView.Types, FMX.ListView.Appearances, FMX.ListView.Adapters.Base, FMX.ListView, FMX.StdActns, FMX.MediaLibrary.Actions, FMX.Objects, FMX.Surfaces; .... procedure TForm1.FormShow(Sender: TObject); var LItem: TListItem; begin LItem := TListItem.Create(ListViewContacts.Items); LItem.Text := 'new item'; @programmerdelphi2k thanks but still same error. Edited December 20, 2022 by William23668 Share this post Link to post
programmerdelphi2k 237 Posted December 20, 2022 you cannot use TListIem.Create in FMX. You should use var LVItem: TListViewItem; begin LVItem := ListView1.Items.Add; LVItem.Text := 'hello'; end; 1 Share this post Link to post
William23668 8 Posted December 20, 2022 (edited) Thanks @programmerdelphi2k copy from forum and paste into Delphi also copy hidden characters but after removing them the code work Edited December 20, 2022 by William23668 Share this post Link to post
skyzoframe[hun] 4 Posted December 20, 2022 hi, check here one solution, how to use Listview in fmx. 1 Share this post Link to post