ListView1ButtonClick

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

ListView1ButtonClick

Postby Lena » Sun May 22, 2016 4:12 am

I read pdf embarcadero book:
Code: Select all
void __fastcall TForm1::ListView1ButtonClick(TObject * const Sender, TListItem * const AItem,
        TListItemSimpleControl * const AObject)
{
 ShowMessage(AItem->Text + " " + AItem->ButtonText + " is clicked.");
}


But in Berlin:
[bcc32 Error] Unit1.cpp(20): E2316 'Text' is not a member of 'TListItem'
[bcc32 Error] Unit1.cpp(20): E2316 'ButtonText' is not a member of 'TListItem'


How correct?
Lena
BCBJ Master
BCBJ Master
 
Posts: 524
Joined: Sun Feb 06, 2011 1:28 pm

Re: ListView1ButtonClick

Postby HsiaLin » Sun May 22, 2016 2:31 pm

ListItems have a ->Caption not ->Text
HsiaLin
BCBJ Master
BCBJ Master
 
Posts: 281
Joined: Sun Jul 08, 2007 6:29 pm

Re: ListView1ButtonClick

Postby minas » Sun May 22, 2016 3:43 pm

The problem is caused because in Berlin version(as I see in documentation) the type of AItem parameter of TItemControlEvent event type has changed ...

http://docwiki.embarcadero.com/Libraries/Berlin/en/FMX.ListView.TAppearanceListView.OnButtonClick

C++ __property Fmx::Listview::Appearances::TItemControlEvent OnButtonClick = {read=FOnButtonClick, write=FOnButtonClick};

C++ typedef void __fastcall (__closure *TItemControlEvent)(System::TObject* const Sender, Fmx::Listview::Types::TListItem* const AItem, Fmx::Listview::Types::TListItemSimpleControl* const AObject);


instead in previous versions (XE7)

http://docwiki.embarcadero.com/Libraries/XE7/en/FMX.ListView.TCustomListView.TItemControlEvent

C++ typedef void __fastcall (__closure *TItemControlEvent)(System::TObject* const Sender, TListViewItem* const AItem, Fmx::Listview::Types::TListItemSimpleControl* const AObject);

so you have to use AItem->Caption
-
User avatar
minas
BCBJ Guru
BCBJ Guru
 
Posts: 196
Joined: Sat Jul 10, 2004 6:09 am
Location: Greece

Re: ListView1ButtonClick

Postby Lena » Sun May 22, 2016 11:31 pm

so you have to use AItem->Caption


No AItem->Caption :(
Attachments
Untitled-1.jpg
Untitled-1.jpg (60.5 KiB) Viewed 4181 times
Lena
BCBJ Master
BCBJ Master
 
Posts: 524
Joined: Sun Feb 06, 2011 1:28 pm

Re: ListView1ButtonClick

Postby Lena » Mon May 23, 2016 12:07 am

It looks like this solution:
Code: Select all
void __fastcall TForm1::ListView1ButtonClick(TObject * const Sender, TListItem * const AItem,
        TListItemSimpleControl * const AObject)
{
 ShowMessage(static_cast< TListViewItem * >(AItem)->Text + " " +
             static_cast< TListViewItem * >(AItem)->ButtonText + " is clicked.");
}
Lena
BCBJ Master
BCBJ Master
 
Posts: 524
Joined: Sun Feb 06, 2011 1:28 pm

Re: ListView1ButtonClick

Postby minas » Mon May 23, 2016 2:15 am

Ooops
I see in Docwiki , there is not Caption property for TListItem.
Since TListViewItem contains(deriving from) TListItem , static_cast is the way to go as you have already done...
-
User avatar
minas
BCBJ Guru
BCBJ Guru
 
Posts: 196
Joined: Sat Jul 10, 2004 6:09 am
Location: Greece

Re: ListView1ButtonClick

Postby rlebeau » Mon May 23, 2016 2:36 pm

Remy Lebeau (TeamB)
Lebeau Software
User avatar
rlebeau
BCBJ Author
BCBJ Author
 
Posts: 1457
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA


Return to Technical

Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 9 guests