Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TdxBarMRUListItem Class

TdxBarMRUListItem is used to represent a list of most recently used (MRU) items within toolbars.

#Declaration

Delphi
TdxBarMRUListItem = class(
    TdxBarListItem
)

#Remarks

TdxBarMRUListItem allows you to implement a list of most recently used (MRU) items into your application. This feature can dramatically extend the functionality of your application. For instance, you can use this item to display the list of recently used files in a submenu. This list changes when you close file.

The following procedure adds the closed file to the MRU file list:

procedure TChildForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  if MainForm.FileName <> '' then
    MainForm.dxBarMRUFiles.AddItem(MainForm.FileName, nil);
  Action := caFree;
end;

The following procedure uses the MRU list to open one of the recently used files:

procedure TMainForm.dxBarMRUFilesClick(Sender: TObject);
var
  AFileName: String;
begin
  AFileName := dxBarMRUFiles.Items[dxBarMRUFiles.ItemIndex];
  if FileExists(AFileName) then
    with TChildForm.Create(Application) do
    begin
      FileName := AFileName;
      Editor.Lines.LoadFromFile(FileName);
      SetModified(False);
    end
  else
    Application.MessageBox(PChar(AFileName+#10#13+'File not found.'),'Open',MB_OK or MB_ICONERROR)
end;
See Also