Skip to main content

TcxTreeListStyles.OnGetColumnHeaderStyle Event

Occurs whenever a column header needs repainting.

Declaration

property OnGetColumnHeaderStyle: TcxTreeListGetColumnStyleEvent read; write;

Remarks

This event occurs every time a TreeList column header is repainted. This allows you to substitute the assigned column header style by another style. Alternatively, you can use the Header property to define the style settings of a column header.

To change the style, you should write an event handler that passes the existing instance of the TcxStyle class to the control via the AStyle parameter. Note that the AStyle parameter doesn’t represent any TcxStyle instance and is nil by default. So you can’t implement the following code:

AStyle.Color := clBlack

before you assign a TcxStyle instance to it.

The following code is not recommended either:

AStyle := TcxStyle.Create;

In this case, a TcxStyle instance will be created every time the event occurs and will never be removed until application termination. Implementing the above code creates excessive TcxStyle instances and excessive memory usage as the result. The correct method is to create a TcxStyle instance outside the event handler and pass it to the control via the AStyle parameter within the event handler. For instance, you can use the StyleRepository to create and store your custom styles.

The Sender parameter contains the TreeList control instance that owns the style collection.

The AColumn parameter contains the TreeList column whose header is being repainted.

The initial style for column headers is determined by the TcxTreeListStyles.ColumnHeader property.

See Also