TcxCustomColorComboBoxProperties.OnAddedMRUColor Event
Fires after a color has been added to the most recently used list or when a color was moved to the top of it.
Declaration
property OnAddedMRUColor: TNotifyEvent read; write;
Remarks
When a user selects a color that is not in the most recently used list, the color is added to the top of that list. If the selected color is already in the list, but not at the top, it is moved to that position. The OnAddedMRUColor event fires for both cases. The event’s Sender parameter specifies the color box control whose most recently used list has been changed.
If a color is removed from the most recently used list, the OnDeletedMRUColor event is raised.
The OnAddedMRUColor event can be used for synchronizing most recently used lists of several editors. When a color is added to the list of an editor, this editor’s most recently used list must be written to a global version. When a dropdown window of an editor is invoked, the global most recently used list must be assigned to this editor. For this purpose, the OnAddedMRUColor and OnInitPopup events of all the synchronized editors must be handled in the same manner. The code below shows how you can do this. (The list of the most recently used colors is available via the MRUColors property.)
type
TForm1 = class(TForm)
// ...
public
MRUGlobal: TcxColorComboBoxItems;
// ...
constructor TForm1.Create(AOwner: TComponent);
begin
inherited;
MRUGlobal := TcxColorComboBoxItems.Create(Self, TcxColorComboBoxItem);
end;
procedure TForm1.cxColorComboBox1PropertiesInitPopup(Sender: TObject);
begin
(sender as TcxColorComboBox).Properties.MRUColors.Assign(MRUGlobal);
end;
procedure TForm1.cxColorComboBox1PropertiesAddedMRUColor(Sender: TObject);
var
GridColorCombo : TcxColorComboBoxProperties;
begin
GridColorCombo := Sender as TcxColorComboBoxProperties;
MRUGlobal.Assign(GridColorCombo.MRUColors);
end;
Note
the most recently used feature is available if the MaxMRUColors property is set to a value greater than 0.