Форум: "Базы";
Текущий архив: 2002.04.08;
Скачать: [xml.tar.bz2];
ВнизКак отобразить в DBGrid номер строки? Найти похожие ветки
← →
MAxiMum (2002-03-14 14:56) [0]Да, был поставлен такой вопрос. Я решил его с помощью кода, приведённого ниже, но при прокрутке - номера опять с единицы. Я понимаю ARow - хранит номер строки, но, что делать. Испробовал иногое - не помогает.
type
TMAxDBGrid = class(TDBGrid)
private
procedure UpdateIndicator;
protected
procedure SizeChanged(OldColCount: Integer; OldRowCount: Integer); override;
public
procedure DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState); override;
procedure SetColumnAttributes; override;
end;
{...}
procedure TMAxDBGrid.DrawCell(ACol, ARow: Integer; ARect: TRect;
AState: TGridDrawState);
//var ALeft: Integer;
begin
inherited;
{MAxIntLength - длина числа в символах}
if (gdFixed in AState) then
with Canvas do
if ACol = 0 then
begin
Font.Style := Font.Style + [fsBold];
Font.Color := clWindowText;
if ARow = 0 then// TextOut(ARect.Left + 2, ARect.Top + 2, "№")
else TextOut(ARect.Left + (TextWidth("7") * (MAxIntLength(RowCount - 1) - MAxIntLength(ARow)) div 2) + 2, ARect.Top + 2, IntToStr(ARow))
end
end;
procedure TMAxDBGrid.SetColumnAttributes;
begin
inherited;
UpdateIndicator;
end;
procedure TMAxDBGrid.SizeChanged(OldColCount, OldRowCount: Integer);
begin
inherited;
if (ComponentState <> []) and not (csDesigning in ComponentState) and (SelectedIndex >= 0) then UpdateIndicator;
end;
procedure TMAxDBGrid.UpdateIndicator;
begin
if dgIndicator in Options then ColWidths[0] := IndicatorWidth + Canvas.TextWidth("7") * MAxIntLength(RowCount - 1) + 2;
end;
Страницы: 1 вся ветка
Форум: "Базы";
Текущий архив: 2002.04.08;
Скачать: [xml.tar.bz2];
Память: 0.44 MB
Время: 0.006 c