0

It is easy to find examples to add a Header item to a TListView in Delphi. I'm having no luck finding such for c++. I'm trying to translate this code from Object Pas to c++ but I can't figure out a translation for the "Purpose.Header".

with ListView1.Items.Add do
    begin
      Text := Format('Header %d', [Group]);
      Purpose := TListItemPurpose.Header;
    end;

In c++ I have this:

ListView1->BeginUpdate();
TListViewItem* item = ListView1->Items->Add();
item->Purpose = ??????????  // this is the line I need syntax for
item->Text = "My Header";
ListView1->EndUpdate();
4

1 回答 1

1

TListItemPurpose是枚举类型。FireMonkey 编译时启用了作用域枚举(C++11 及更高版本中的强类型枚举)。

您显示的 Delphi 代码转换为 C++,如下所示:

TListViewItem *Item = ListView1->Items->Add();
Item->Text = Format(L"Header %d", ARRAYOFCONST(( Group )));
Item->Purpose = TListItemPurpose::Header; 
于 2018-04-06T03:25:32.223 回答