Skip to main content

TcxCustomControlStyles.OnGetContentStyle Event

Fires when the editing control content is about to be painted.

Declaration

property OnGetContentStyle: TcxOnGetContentStyleEvent read; write;

Remarks

The OnGetContentStyle event occurs every time the editing control content is about to be painted. This allows you to substitute the assigned content style for any other style.

Data-representing editing controls (such as TreeList) use the content style for data-representing cells. The event is fired when a single cell needs to be repainted. This allows you to change the style for every visible data cell.

To change the content style, you should write an event handler that passes an EXISTING TcxStyle class instance 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 couldn’t implement the following code:

AStyle.Color := clBlack

before assigning 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 be never deleted until the application termination. Implementing the above code creates excessive TcxStyle instances and excessive memory usage as a result. The proper method is to create a TcxStyle instance outside the event handler but pass it to the control via the AStyle parameter within the event handler. For instance, you can use the TcxStylesRepository component to create and store your custom styles.

The Sender parameter of the event contains the editing control that owns the styles collection.

The AData parameter is reserved in this event. You can use it in your own controls to pass specific event data. Editing controls override the OnGetContentStyle event where the AData parameter is replaced with the parameters specific to the control. See the TcxTreeListStyles.OnGetContentStyle event for details.

See Also