I am stumped! D5ent.
I have a form with a dozen design-time SpeedButtons on them.
I have a dataset with the Caption, the Hint and a Glyph for all twelve buttons.
When I run the database I can assign the Caption, Hint, select and store a Bitmap for the Glyph.
When I use the DBNavigator to step through, it correctly shows the individual DBImage with each Bitmap for each button. However at runtime, not so.
I have this code that steps though the dataset and when I ShowModal the form all of the buttons have the correct individual Captions and Hints, but they all have the same Glyph from the first button.
procedure LoadButtons;
procedure SetButton(var aBtn : TSpeedButton);
begin
aBtn.Hint:=tblButtons.FieldByName('Hint').AsString;
aBtn.Caption:=tblButtons.FieldByName('Caption').AsString;
aBtn.Glyph.Assign(dbimgButton.Picture.Bitmap);
end;
begin
tblButtons.First;
BtnCtr:=1;
repeat
case BtnCtr of
1 : SetButton(btn1);
2 : SetButton(btn2);
3 : SetButton(btn3);
// ... to twelve
end;
tblButtons.Next;
Inc(BtnCtr);
until tblButtons.EOF;
end;
end;
Where am I going wrong? I have messed with Update, AutoDisplay, LoadPicture etc…
Thanks
If you’re using
DisableControlsthen db-aware controls are not updated while looping through the dataset. If you’re assinging the glyph from such a control then that’s the reason why all buttons have the glyph of the first record.