Back to Devexpress

TdxListViewCreateItemClassEvent Type

vcl-dxlistview-93a1d259.md

latest2.0 KB
Original Source

TdxListViewCreateItemClassEvent Type

The procedural type for list item creation handlers.

Declaration

delphi
TdxListViewCreateItemClassEvent = procedure(Sender: TdxCustomListView; var AItemClass: TdxListItemClass) of object;

Parameters

NameTypeDescription
SenderTdxCustomListView

The List View control that raised the event.

| | AItemClass | TdxListItemClass |

A class-reference to the added item class. The assigned class should be a descendant of the TdxListItem class.

|

Remarks

The following code specifies a TdxListItem class descendant whose instances store their time of creation and the ListView’s OnCreateItemClass event handler that adds the custom-defined item instead of the standard item:

delphi
type
  MyItem = class(TdxListItem)
  private
    Created: TDateTime;
  public
    constructor Create(AOwner: TdxListItems); virtual;
end;

constructor MyItem.Create(AOwner: TdxListItems);
begin
  inherited Create(AOwner);
  Created := Now;
end;

procedure TForm1.dxListViewControl1CreateItemClass(Sender: TdxCustomListView;
  var AItemClass: TdxListItemClass);
begin
  AItemClass := MyItem;
end;
cpp
class MyItem : TdxListItem
{
  private:
    TDateTime Created;
  public
    __fastcall virtual MyItem(TdxListItems *AOwner : TdxLiostItem(AOwner)
    {
      Created = Now();  
    }
}

void __fastcall TForm1::dxListViewControl1CreateItemClass(TdxCustomListView *Sender,
  TdxListItemClass &AItemClass)
{
  AItemClass = __classid(MyItem);
}

The List View’s OnCreateItemClass event references the TdxListViewCreateItemClassEvent type.

See Also

dxListView Unit