Ever since (I think) XE5 I have problems that the ColumnHeaders in ListViews sometimes are not rendered (including the background) when the Form is Shown. Form type is bsDialog.
While the ListView works normally, and the contents are rendered normally, the headers are white.
Clicking on a columnheader will render that specific header.
The problem occurs from Windows XP, windows7 to windows 8.1.
I have one ListView, code below, which is the worst of the lot. Nearly every time no headers. Does anybody see any stupid mistakes in it??
The Application is compiled with Runtime Themes _disabled_.
ListView settings are default, see below.
Thanks, Bart
{code}
procedure TPeopleArrivalForm.RefreshPeopleListView(DoClear:boolean);
var
Index, ACount: integer;
ListItem : TListItem;
begin
if DoClear then
begin
PeopleListView.Clear;
end;
ACount := 0;
if PeopleList.Count > 100 then Screen.Cursor := crAppStart;
PeopleListView.SortType := stNone;
PeopleListView.Items.BeginUpdate;
try
try
for Index := 0 to PeopleList.Count-1 do
with PeopleList[index] do
begin
ListItem := nil;
if (NOT DoClear) then
begin
if PeopleArrivalListItem = nil
then ListItem := GetPeopleListMemberID(3,PeopleList[index].MemberID)
else ListItem := PeopleArrivalListItem;
end;
if ListItem = nil then // New ListView entry
begin
ListItem := PeopleListView.Items.Add;
ListItem.Caption := SurName;
ListItem.SubItems.Add(FirstName);
ListItem.SubItems.Add(StatusToText(Status));
ListItem.SubItems.Add(MemberID);
PeopleList[index].PeopleArrivalListItem := ListItem;
end else
begin
ListItem.SubItems[1] := StatusToText(Status);
end;
end;
except
on E:Exception do Log('PeopleArrivalForm.RefreshPeopleListView: '+E.Message,d_error);
end;
finally
PeopleListView.Items.EndUpdate;
PeopleListView.SortType := stText;
PeopleListView.Refresh;
Edit1.SetFocus;
Screen.Cursor := crDefault;
end;
end;
procedure TPeopleArrivalForm.PeopleListViewCustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
var
APeople: TPeople;
IconIndex: integer;
begin
if not Assigned(Item) then
begin
Log('PeopleArrivalForm.PeopleListViewCustomDrawItem: Item not assigned!',D_ERROR);
exit;
end;
APeople := PeopleList.GetPeopleByID(Item.SubItems[2]); // ID field
if APeople = nil then
begin
Log('PeopleArrivalForm.PeopleListViewCustomDrawItem: Index not found of PeopleID '+ Item.SubItems[2],D_ERROR);
exit;
end;
with APeople do
begin
if Status = asUnavailable then
begin
PeopleListView.Canvas.Font.Color := clBlack;
PeopleListView.Canvas.Brush.Color := PeopleSettings.UnavailableColor;
IconIndex := 62;
end else
if Status = asAvailable then
begin
PeopleListView.Canvas.Font.Color := clblack;
PeopleListView.Canvas.Brush.Color := PeopleSettings.AvailableColor;
IconIndex := 76;
end else
if Status = asArrived then
begin
PeopleListView.Canvas.Font.Color := clblack;
PeopleListView.Canvas.Brush.Color := PeopleSettings.ArrivedColor;
IconIndex := 77;
end else
if Status = asAssigned then
begin
PeopleListView.Canvas.Font.Color := clBlack;
PeopleListView.Canvas.Brush.Color := PeopleSettings.AssignedColor;
IconIndex := 78;
end else
begin
IconIndex := 0;
PeopleListView.Canvas.Brush.Color := clWhite;
// Log('PeopleArrivalForm.PeopleListViewCustomDrawItem: Bad Status: '+IntToStr(Status),d_error);
end;
Item.ImageIndex := IconIndex;
end;
end;
{code}
{code}
object PeopleListView: TListView
Left = 0
Top = 22
Width = 298
Height = 302
Hint = 'Right-click to change Status'
Align = alClient
Columns = <
item
Caption = 'Surname'
Width = 100
end
item
Caption = 'Firstname'
Width = 60
end
item
Caption = 'Status'
Width = 70
end
item
Caption = 'ID'
end>
DoubleBuffered = True
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
GridLines = True
ReadOnly = True
RowSelect = True
ParentDoubleBuffered = False
ParentFont = False
ParentShowHint = False
ShowHint = True
SmallImages = ICONForm.IconList16Bit
TabOrder = 0
ViewStyle = vsReport
OnColumnClick = PeopleListViewColumnClick
OnCompare = PeopleListViewCompare
OnCustomDrawItem = PeopleListViewCustomDrawItem
OnMouseDown = PeopleListViewMouseDown
end
{code}
--
Bart Kindt, CEO and developer
SARTrack Limited New Zealand
http://www.sartrack.co.nz/
> {quote:title=Martin Buchmajer wrote:}{quote}
Thanks for that, Bart
> Hello, I use DelphiXE2.
> I have a similar problem, sometimes the Columns.Caption does not appear in TListView after running form.
> Problem solved by Form.OnActivate to add resizing ListView.Column [0] .Width.
>
> Martin B.
--
Bart Kindt, CEO and developer
SARTrack Limited New Zealand
http://www.sartrack.co.nz/
> {quote:title=Bart Kindt wrote:}{quote}
> Ever since (I think) XE5 I have problems that the ColumnHeaders in ListViews sometimes are not rendered (including the background) when the Form is Shown. Form type is bsDialog.
>
>
Hello, I use DelphiXE2.
I have a similar problem, sometimes the Columns.Caption does not appear in TListView after running form.
Problem solved by Form.OnActivate to add resizing ListView.Column [0] .Width.
Martin B.
> {quote:title=Remy Lebeau (TeamB) wrote:}{quote}
> In my case, I simply roll the mouse over the headers, that is usually good
> enough to get them redrawn.
Not here. I have to actually click on a column header to force it to redraw itself. This happens of course because it does a down/up (Column Click is enabled).
Bart
--
Bart Kindt, CEO and developer
SARTrack Limited New Zealand
http://www.sartrack.co.nz/
Bart wrote:
> Ever since (I think) XE5 I have problems that the ColumnHeaders in
> ListViews sometimes are not rendered (including the background)
> when the Form is Shown. Form type is bsDialog.
I have seen this happen in non-VCL apps, like TortoiseSVN's commit dialog,
so it is not unique to TListView. Must be an issue with the underlying ListView
control.
> Clicking on a columnheader will render that specific header.
In my case, I simply roll the mouse over the headers, that is usually good
enough to get them redrawn.
--
Remy Lebeau (TeamB)