我这儿有类似速达的表格控件源码,如果有人能帮忙改进的话我就公开源码!(3)
finally
DataLink.ActiveRecord := OldActive;
end;
if DefaultDrawing and (gdSelected in AState)
and ((dgAlwaysShowSelection in Options) or Focused)
and not (csDesigning in ComponentState)
and not (dgRowSelect in Options)
and (UpdateLock = 0)
and (ValidParentForm(Self).ActiveControl = Self) then
Windows.DrawFocusRect(Handle, ARect);
end;
end;
end;
var
OldActive: Integer;
// Indicator: Integer;
Highlight: Boolean;
Value: string;
// MultiSelected: Boolean;
// ALeft: Integer;
DrawColumn: TQLColumn;
SaveColor: TColor;
begin
SaveColor := Color;
FColorChangeLocked := True;
try
if Odd(ARow - TitleOffset) then Color := AlternateColor;
finally
FColorChangeLocked := False;
end;
try
if ((gdFixed in AState) and (ACol < IndicatorOffset)) or
not Assigned(DataLink) or not DataLink.Active or (ARow - TitleOffset < DataLink.RecordCount) then
inherited DrawCell(ACol, ARow, ARect, AState)
else begin
DrawDataCell(ACol, ARow, ARect, AState);
end;
// Dec(ACol, IndicatorOffset);
// Dec(ARow, TitleOffset);
// DrawColumn := Columns[ACol];
// ARow >= FFooterRowCount - RowCount + ARow + FTitleOffset
if (FFooterRowCount - RowCount + ARow >= 0) and (ACol >= IndicatorOffset) then
begin
// Dec(ACol, IndicatorOffset);
// Dec(ARow, TitleOffset);
// DrawColumn := Columns[ACol];
DrawFooterCell(ACol, ARow, ARect);//财务
Exit;
end;
// if (gdFixed in AState) or ((ARow <= DataLink.DataSet.RecordCount) and
// ((ARow - TitleOffset < DataLink.RecordCount) or
// ((DataLink.DataSet.State = dsInsert) and ((ARow - TitleOffset + 1) = DataLink.RecordCount)))) then
// inherited DrawCell(ACol, ARow, ARect, AState)
// else
// DrawDataCell(ACol, ARow, ARect, AState);
// Draw Currency Cell
if (dgCurrencyView in OptionsEx) and not ((gdFixed in AState) and (ACol < IndicatorOffset)) and
not (csLoading in ComponentState) then
begin
if Assigned(DataLink) and DataLink.Active then
begin
Dec(ACol, IndicatorOffset);
Dec(ARow, TitleOffset);
DrawColumn := Columns[ACol];
with DrawColumn do
if not Showing or
(not (Assigned(Field) and
((Field is TCurrencyField) or
((Field is TFloatField) and TFloatField(Field).Currency) or
((Field is TBCDField) and TBCDField(Field).Currency) or
((Field is TAggregateField) and TAggregateField(Field).Currency)))) then Exit;
with Canvas do
begin
// FCurrencyView.DigitWidth := TextWidth('0') + 4;
if (gdFixed in AState) and ([dgRowLines, dgColLines] * Options =
[dgRowLines, dgColLines]) then
begin
InflateRect(ARect, -1, -1);
FrameOffs := 1;
end
else FrameOffs := 2;
if not (gdFixed in AState) then
begin
Font := DrawColumn.Font;
Brush.Color := DrawColumn.Color;
end;
if (ARow < 0) and FCurrencyView.CurrencyTitle then
DrawCurrencyTitleCell(ACol + IndicatorOffset, ARow, DrawColumn, AState)//表头
else if (ARow >= 0) and not (DataLink = nil) and DataLink.Active then
begin
// Value := '';
OldActive := DataLink.ActiveRecord;
try
DataLink.ActiveRecord := ARow;
Highlight := HighlightCell(ACol, ARow, Value, AState);
if Highlight then
begin
Brush.Color := clHighlight;
Font.Color := clHighlightText;
end;
if not Enabled then Font.Color := clGrayText;
if DefaultDrawing then
DrawCurrencyCell(ACol + IndicatorOffset, ARow + TitleOffset, DrawColumn, AState);//表体
finally
DataLink.ActiveRecord := OldActive;
end;
// end;
if DefaultDrawing and (gdSelected in AState)
and ((dgAlwaysShowSelection in Options) or Focused)
and not (csDesigning in ComponentState)
and not (dgRowSelect in Options)
and (UpdateLock = 0)
and (ValidParentForm(Self).ActiveControl = Self) then
Windows.DrawFocusRect(Handle, ARect);
end;
end;
end;
end;
finally
FColorChangeLocked := True;
try
Color := SaveColor;
finally
FColorChangeLocked := False;
end;
end;
end;