Federico Pessina
Federico Pessina

Reputation: 209

Delphi - Bug in fmx with ListView and TabControl

I have a TabControl with Two TabItem. Each tabItem has a ListView in it. The OnItemClick event of the listView on the first TabItem execut a 'NextTabAction'.

The problem is that if I select an item in the listView on the second TabItem, its TextColor is White instead of Black. The bug seems to be that if a ListView is on a TabItem that is not the one visible when the application starts, its selectedItem's TextColor will be White.

It is pretty simple to reproduce. I'm using Delphi Tokyo 10.2

If the page is visible on startup, then it looks this way TextColor Black

If the page is not visible on startup, then it looks this other way enter image description here

Is there a way to solve this?

Upvotes: 0

Views: 649

Answers (2)

headfime
headfime

Reputation: 108

This is still a bug in Delphi 11.1 Alexandria. It seems like the style is not loaded, if you use a tab transition to show a list view for the first time.

Workaround

Apply the style manually, I did it in the FormCreate event:

procedure TForm1.FormCreate(Sender: TObject);
begin
  ListView1.ApplyStyleLookup;
end;

Upvotes: 0

dustypup
dustypup

Reputation: 164

This is ordinary behavior for ListView even in Delphi 10.2 update 3. It happens only when you use tab transitions.

I fix this issue with the below code:

procedure TForm1.ListView1UpdateObjects(const Sender: TObject; const AItem:  TListViewItem);
var
  Text: TListItemText;
begin
  Text := TListItemText(AItem.View.FindDrawable('T'));
  if Text <> nil then
    Text.SelectedTextColor := TAlphaColors.Black;
end;

Of course you need to change Drawable name corresponding to your needs...

Upvotes: 2

Related Questions