0
Hello. I am trying to display a list of products within a listbox. Previously a query is loaded and for each order item I add an item inside the listbox. The fact is that I needed to make a change in the style of the listbox item, which after editing and saving a stylebook is added in the form, in design mode the changes are shown on the screen, when compiling the system it always goes back to the default style. I have already done the editing of style defaul and custom, I tried to apply both at runtime on onactive, oncreate and form onshow. I did a test creating a new project and using only one form and applying the same concept and it worked. But when I apply the same thing to the project that I’m working on, it doesn’t work. I’m not being able to apply the style to the project.
Someone’s been through this trouble or something?
The code that implements the addition of the items follows below:
procedure TfrmVisualPed.Button1Click(Sender: TObject);
var
Item:TListBoxItem;
begin
inherited;
if not DM.qryPedidosItens.IsEmpty then
begin
DM.qryPedidosItens.First;
ListBox1.BeginUpdate;
while not DM.qryPedidosItens.Eof do
begin
Item := TListBoxItem.Create(Nil);
item.StyleLookup := 'listboxitembottomdetail';
item.Width := 150;
item.Height := 150;
if FileExists('D:\TEMP\fotos\' + DM.qryPedidosItensCODIGO_PRODUTO.AsString + '.jpg') then
begin
Item.ItemData.Bitmap.LoadThumbnailFromFile('D:\TEMP\fotos\' + DM.qryPedidosItensCODIGO_PRODUTO.AsString + '.jpg',100,100);
end else
begin
Item.ItemData.Bitmap := imgsemfoto.Bitmap;
end;
Item.ItemData.Text := DM.qryPedidosItensCODIGO_PRODUTO.AsString;
item.Parent := ListBox1;
item.OnClick := Nil;
DM.qryPedidosItens.Next;
end;
ListBox1.EndUpdate;
ListBox1.ItemIndex := 0;
Application.ProcessMessages;
end;
end;
Here are some images:
Are you sure you chose a platform-compatible style? There are some only for android, others only for windows, etc...
– Tiago Rodrigues
I’m not really choosing, I’m editing the custom and default just for windows, and I always compile them for the same platform. And for each platform should make the same change in styles, otherwise it has no effect.
– Fernando Cardoso