no member named

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

no member named

Postby Lena » Thu Jun 23, 2016 12:13 am

I try run project from C++ Builder XE6 in new Berlin 10.1:
Code: Select all
//***
FormDetail->TimeEdit1->Time = ListView1->Items->Item[ListView1->ItemIndex]->Data[sText].AsString();
FormDetail->EditAbout->Text = ListView1->Items->Item[ListView1->ItemIndex]->Detail;

[bccaarm Error] MobUnit1.cpp(517): no member named 'Data' in 'Fmx::Listview::Types::TListItem'
[bccaarm Error] MobUnit1.cpp(519): no member named 'Detail' in 'Fmx::Listview::Types::TListItem'
How fix it?
Lena
BCBJ Master
BCBJ Master
 
Posts: 417
Joined: Sun Feb 06, 2011 1:28 pm

Re: no member named

Postby rlebeau » Thu Jun 23, 2016 1:11 pm

Lena wrote:[bccaarm Error] MobUnit1.cpp(517): no member named 'Data' in 'Fmx::Listview::Types::TListItem'
[bccaarm Error] MobUnit1.cpp(519): no member named 'Detail' in 'Fmx::Listview::Types::TListItem'


The TListView component was refactored in Seattle. This is documented:

What's New:

Refactoring of the List View Control

Many members that used to be in TCustomListView are now in a different class or even a different unit. Members that went into a different class continue being a part of TCustomListView through inheritance.

For a detailed list of changes, see Refactoring of the List View Control in Seattle.


Refactoring of the List View Control in Seattle

The RAD Studio Seattle list view API was refactored. The list view and list view item components where divided into different layers to provide a list view API that is more flexible and easier to extend than in XE8.

These changes should barely affect projects that simply use the TListView component. However, these changes may notably affect projects that subclass a list view or list view item class.

1 TCustomListView Has Been Divided into Five Classes
2 TListViewItems Has Been Divided into Four Classes
3 Object Appearance Classes Have Been Moved to FMX.ListView.Appearances
4 TListItemObject Has Been Renamed and Changed
5 TListItem Has Undergone Some Changes
6 There Have Been Other Changes


Lena wrote:How fix it?


You need to update your code to account for the new class hierarchy.

In XE6, the TListView::Items property is a Fmx::Listview::TListViewItems, whose Item[] property returns a Fmx::Listview::TListViewItem, which has Data and Detail properties.

In Seattle and later, the TListView::Items property is now a Fmx::Listview::Appearances::TAppearanceListViewItems, whose Item[] property returns a generic Fmx::Listview::Types::TListItem, which does not have Data or Detail properties, thus your compiler error.

You need to explicitly type-cast the TListItem to Fmx::Listview::Appearances::TListViewItem (or even Fmx::Listview::Appearances::TAppearanceListViewItem) to access its Data and Details properties:

Code: Select all
TListViewItem *pItem = static_cast<TListViewItem*>(ListView1->Items->Item[ListView1->ItemIndex]);

//or:
//TAppearanceListViewItem *pItem = static_cast<TAppearanceListViewItem*>(ListView1->Items->Item[ListView1->ItemIndex]);

FormDetail->TimeEdit1->Time = pItem->Data[sText].AsString();
FormDetail->EditAbout->Text = pItem->Detail;
Remy Lebeau (TeamB)
Lebeau Software
User avatar
rlebeau
BCBJ Author
BCBJ Author
 
Posts: 1375
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA

Re: no member named

Postby Lena » Fri Jun 24, 2016 12:27 am

Thanks a lot for detailed answer!
Lena
BCBJ Master
BCBJ Master
 
Posts: 417
Joined: Sun Feb 06, 2011 1:28 pm


Return to Technical

Who is online

Users browsing this forum: No registered users and 4 guests

cron