![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Как отобразить в DBGrid номер строки? [D6]
MAxiMum © (2002-03-14 14:56:00)Да, был поставлен такой вопрос. Я решил его с помощью кода, приведённого ниже, но при прокрутке - номера опять с единицы. Я понимаю 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;
data (2002-03-14 18:17:00) [1]2 MAxiMum © (14.03.02 17:02)
Посмотрите эту ветку
http://delphi.mastak.ru/cgi-bin/forum.pl?look=1&id=1015898975&n=1
MAxiMum (2002-03-14 17:02:00) [2]>SVM
У меня наряду с запросами используются и таблицы.
Надо, чтобы было универсально. Притом, у меня отображается всё вместе с индикатором - это здорово и красиво.
Да уж, ответ где-то рядом...
Johnmen (2002-03-14 15:08:00) [3]А ты поройся в конфе - был очень интересный ответ, причем, как говорят, работающий !
SVM (2002-03-14 15:02:00) [4]Создай поле (вычисляемое или в запросе) и выводи его.