Hi,
I got this code from you for drawing the header yourself in ExpressGrid 5 and this seems necessary still in the new ExpressGrid 6 (if you want to sort by another field than the one shown in the grid). This old code does not show the new header highlighting correctly though. Do you have some new code for this?
Here is the old code:
procedure TViewManager_frm.grid_ViewEntryDBBandedTableView1TitleCustomDrawHeader(
Sender: TcxGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxGridColumnHeaderViewInfo; var ADone: Boolean);
var
I: Integer;
R: TRect;
begin
with AViewInfo do
begin
Sender.Painter.LookAndFeelPainter.DrawHeader(ACanvas, Bounds, TextAreaBounds,
Neighbors, Borders, cxbsNormal, taLeftJustify, vaTop, False, False, Column.Caption, ACanvas.Font, clNone, Color);
with TcxGridColumnHeaderViewInfoAccess(AViewinfo) do
for I := 0 to AreaViewInfoCount - 1 do
begin
if AreaViewInfos[I] is TcxGridColumnHeaderFilterButtonViewInfo then
Sender.Painter.LookAndFeelPainter.DrawFilterDropDownButton(Canvas, AreaViewInfos[I].Bounds,
GridCellStateToButtonState(AreaViewInfos[I].State), TcxGridColumnHeaderFilterButtonViewInfo(AreaViewInfos[I]).Active);
R := AreaViewInfos[I].Bounds;
R.Right := AreaViewInfos[I].Bounds.Left - 2;
R.Left := R.Right - Sender.Painter.LookAndFeelPainter.SortingMarkSize.X;
R.Bottom := R.Bottom - 4;
R.Top := R.Top + 4;
end;
if grid_ViewEntryDBBandedTableView1TitleSort.SortOrder <> soNone then
begin
ACanvas.Brush.Color := AViewInfo.Params.Color;
InflateRect(R, 1, 1);
ACanvas.FillRect®;
InflateRect(R, -1, -1);
Sender.Painter.LookAndFeelPainter.DrawSortingMark(ACanvas, R, grid_ViewEntryDBBandedTableView1TitleSort.SortOrder = soAscending);
end;
ADone := True;
end;
end;
Best Regards,
Johan
Hi Johan,
Attached is a small sample project demonstrating how to accomplish this task in the ExpressQuantumGrid v6. Please review it and let us know your results.
Thanks,
Vito
Hi,
This works like the previous example I got. It does not highlight the header
when the mouse-pointer is over it (like the other columns). You can see this
in your own example by setting LookAndFeel.NativeStyle to True. All column
headers will then be highlighted except the one that got the
CustomDrawHeader event. Do you have some code to fix this?
Let me know if I can be of any further assistance.
Best Regards,
Johan
Hi,
This gives the same result as my old code. The sort works but the header is
not drawn correctly. There are two problems:
event; they are not highlighted correctly when the LookAndFeel.NativeStyle
property is set to true.
ugly and out of place.
Do you have some revised code where at least the first problem is resolved?
Thanks!
Best Regards,
Johan
Hi Johan,
Thank you for the detailed description of the problem.
Attached is the modified sample project, which seems to process these situations correctly. Please review it and let us know your results.
BTW, this task also can be accomplished by handling the OnCompare event. Please refer to the "How to sort a column by the values in another (hidden) column?" report (www.devexpress.com/issue=CQ58532) to find more information on this subject.
Thanks,
Vito
Thanks Vito that fixed it.
I can't try the OnCompare alternative though since the Delphi 7 helpfiles and Vista is no good combination :) Can you copy and send the example and helptext?
-- Johan