Making it more flexible lazarus / 21-General ---------------------------------------------------------------------- madref · 2024-07-07 22:57 I am using the following code to add images to a TDBLookupComboBox. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm_Wedstrijd_Overzicht.CB_DivisieDrawItem(Control: TWinControl; Index: Integer; ARect: TRect; State: TOwnerDrawState);begin//  CB_Divisie.Canvas.FillRect(ARect);  CB_Divisie.Canvas.TextRect(ARect, 30, ARect.Top + 5, CB_Divisie.Items[Index]);  ImageList_Divisie.Draw(CB_Divisie.Canvas, ARect.Left + 10, ARect.Top + 5, Index);end;     // CB_DivisieDrawItem  procedure TForm_Wedstrijd_Overzicht.Verander_Divisie_ImageList;var tqd: TSQLQuery;    b: integer;begin  ImageList_Divisie.Clear;  tqd := TSQLQuery.Create(self);  tqd.DataBase := Form_Lint.Connect_RefereeDB;  tqd.SQL.Clear;  tqd.SQL.Text := 'SELECT Divisie_ID, Divisie_Volgorde, Divisie_Gebruiken, Divisie_Bond ' +                  'FROM tbl_Divisie INNER JOIN tbl_Wedstrijden ON ' +                  'tbl_Wedstrijden.Wed_Divisie = tbl_Divisie.Divisie_ID ' +                'WHERE ((Wed_Seizoen_ID = :Wed_Seizoen_ID) OR :Wed_Seizoen_ID = 0) ' +                  'GROUP BY Divisie_ID ' +                  'UNION SELECT Divisie_ID, Divisie_Volgorde, Divisie_Gebruiken, Divisie_Bond ' +                  'FROM tbl_Divisie  ' +                  'WHERE Divisie_ID = 1 ' +                  'GROUP BY Divisie_ID ' +                'ORDER BY Divisie_Volgorde;';  tqd.Params.ParamByName('Wed_Seizoen_ID').AsInteger := CB_Seizoen.KeyValue;  tqd.Open;  tqd.First;  while not tqd.Eof do  begin    b := tqd.FieldByName('Divisie_Bond').AsInteger;    case b of        1 : ImageList_Divisie.AddImages(ImageList_IIHF);        2 : ImageList_Divisie.AddImages(ImageList_NIJB);        3 : ImageList_Divisie.AddImages(ImageList_BeNe);        4 : ImageList_Divisie.AddImages(ImageList_RHC);        5 : ImageList_Divisie.AddImages(ImageList_HNA);    else      ImageList_Divisie.AddImages(ImageList_IIHF);    end;    tqd.Next;  end;  tqd.Active := False;  tqd.Free;end;     // Verander_Divisie_ImageList  But now I want to make it more flexible so that I can use external images (16x16 pixels) How do i do that? Can any one help me out? p.s. In the attachment you see the result ---------------------------------------------------------------------- paweld · 2024-07-08 14:01 the way I would do it is that in the tbl_Divisie table I would add an additional column of type BLOB where the logo/icon would be stored. And in the query you provided, you would add this column, and for each record that doesn't have an assigned logo, you would set the default (from TImageList), and if it has one assigned, you would then assign the one retrieved from the database.