From 5b4afdd2dfd3ff64f75a86968ef9045829e2300a Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Sun, 21 Apr 2024 16:08:14 +0200 Subject: [PATCH] Grid export: convert format TComboBox to TComboBoxEx with icons --- source/exportgrid.dfm | 29 +++++++++++++++++++---------- source/exportgrid.pas | 12 ++++++++---- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/source/exportgrid.dfm b/source/exportgrid.dfm index aacaaa31..6ad3f34f 100644 --- a/source/exportgrid.dfm +++ b/source/exportgrid.dfm @@ -280,21 +280,30 @@ object frmExportGrid: TfrmExportGrid DesignSize = ( 558 50) - object comboFormat: TComboBox + object comboFormat: TComboBoxEx Left = 8 Top = 18 Width = 540 - Height = 22 - Style = csDropDownList + Height = 23 + ItemsEx = < + item + Caption = 'Excel CSV' + ImageIndex = 49 + SelectedImageIndex = 49 + end + item + Caption = 'CSV' + ImageIndex = 50 + SelectedImageIndex = 50 + end + item + Caption = '...' + end> + Style = csExDropDownList Anchors = [akLeft, akTop, akRight] - DropDownCount = 20 - ItemIndex = 0 TabOrder = 0 - Text = 'Excel CSV' - Items.Strings = ( - 'Excel CSV' - 'Delimited Text' - '...') + Images = MainForm.VirtualImageListMain + DropDownCount = 20 end end object popupCSVchar: TPopupMenu diff --git a/source/exportgrid.pas b/source/exportgrid.pas index 0f8a73b1..bc62f4c2 100644 --- a/source/exportgrid.pas +++ b/source/exportgrid.pas @@ -67,7 +67,7 @@ type btnSetClipboardDefaults: TButton; chkRemoveLinebreaks: TCheckBox; grpFormat: TGroupBox; - comboFormat: TComboBox; + comboFormat: TComboBoxEx; procedure FormCreate(Sender: TObject); procedure CalcSize(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); @@ -170,8 +170,9 @@ uses main, apphelpers, dbconnection; procedure TfrmExportGrid.FormCreate(Sender: TObject); var - FormatDesc: String; + ef: TGridExportFormat; SenderName: String; + comboItem: TComboExItem; begin HasSizeGrip := True; editFilename.Text := AppSettings.ReadString(asGridExportFilename); @@ -180,8 +181,11 @@ begin comboEncoding.Items.Delete(0); // Remove "Auto detect" comboEncoding.ItemIndex := AppSettings.ReadInt(asGridExportEncoding); comboFormat.Items.Clear; - for FormatDesc in FormatToDescription do - comboFormat.Items.Add(FormatDesc); + for ef:=Low(TGridExportFormat) to High(TGridExportFormat) do begin + comboItem := TComboExItem.Create(comboFormat.ItemsEx); + comboItem.Caption := FormatToDescription[ef]; + comboItem.ImageIndex := FormatToImageIndex[ef]; + end; SenderName := Owner.Name; FHiddenCopyMode := SenderName.StartsWith(CopyAsActionPrefix);