procedure TForm1.ListView1ColumnClick(Sender: TObject; Column: TListColumn);
begin
FColumnToSort := Column.Index;
ListView1.Invalidate;
end;
procedure TForm1.ListView1CustomDraw(Sender: TCustomListView; const ARect: TRect; var DefaultDraw: Boolean);
var
ColLeft: Integer;
ColBounds: TRect;
I: Integer;
begin
ColLeft := ARect.Left;
for I := 0 to Pred(FColumnToSort) do
ColLeft := ColLeft + ListView_GetColumnWidth(ListView1.Handle, I);
ColBounds := Rect(ColLeft, ARect.Top, ColLeft + ListView_GetColumnWidth(ListView1.Handle, FColumnToSort), ARect.Bottom);
ListView1.Canvas.Brush.Color := clSilver;
ListView1.Canvas.FillRect(ColBounds);
end;
THIS BLOG IS AIMED AT DELPHI, C#.NET, ASP.NET PROFESSIONALS WHO ARE NEW TO THE COMMUNITY AND LOOKING FOR TIPS AND TRICKS. IT WILL HOPEFULLY SHOW YOU HOW AND WHERE TO GET HELP BUT WILL NOT TELL YOU HOW TO DO YOUR JOB - THAT BIT IS UP TO YOU.
Thursday, July 26, 2007
Display a shaded column like Windows Explorer in XP
The Windows Explorer in XP displays the sorted column in pale grey. We can bring up similar behaviour in Delphi TListView by handling all two OnCustomDraw, OnColumnClick events to display a list view with a specified column shaded in pale grey.
Labels:
Delphi,
OnColumnClick,
OnCustomDraw,
TListView,
VCL
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment