« Reply #2 on: February 05, 2020, 07:56:26 am »
Since no one seems to know a good answer to my question I cam up with a solution myself.Not ideally, but it's crude and it works.You can copy an entire Imagelist to another Imagelist withImageList_1.AddImages(ImageList_2);
So I created 4 Imagelist's to hold each 1 image and with a case-statement I managed to do what I wanted.
So the final code looks like this
procedure TForm_Wedstrijd_Overzicht.Verander_Disvisie_ImageList;
var tqd: TSQLQuery;
b: integer;
begin
ImageList_Divisie.Clear;
tqd := TSQLQuery.Create(self);
tqd.DataBase := Form_RefereeMain.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);
else
ImageList_Divisie.AddImages(ImageList_Niks);
end;
tqd.Next;
end;
// Query uit het geheugen halen.
tqd.Active := False;
tqd.Free;
end; // Verander_Disvisie_ImageList
and then in 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, 25, ARect.Top, CB_Divisie.Items[Index]);
ImageList_Divisie.Draw(CB_Divisie.Canvas, ARect.Left + 1, ARect.Top + 1, Index);
end; // CB_DivisieDrawItem
« Last Edit: February 05, 2020, 07:58:06 am by madref »
Logged
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.
Lazarus 3.99 (rev main_3_99-649-ge13451a5ab) FPC 3.3.1 x86_64-darwin-cocoa
Mac OS X Monterey