Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2002.04.08;
Скачать: CL | DM;

Вниз

Как отобразить в 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;


 
SVM   (2002-03-14 15:02) [1]

Создай поле (вычисляемое или в запросе) и выводи его.


 
Johnmen ©   (2002-03-14 15:08) [2]

А ты поройся в конфе - был очень интересный ответ, причем, как говорят, работающий !


 
MAxiMum ©   (2002-03-14 17:02) [3]

>SVM
У меня наряду с запросами используются и таблицы.
Надо, чтобы было универсально. Притом, у меня отображается всё вместе с индикатором - это здорово и красиво.
Да уж, ответ где-то рядом...


 
data ©   (2002-03-14 18:17) [4]

2 MAxiMum © (14.03.02 17:02)
Посмотрите эту ветку
http://delphi.mastak.ru/cgi-bin/forum.pl?look=1&id=1015898975&n=1



Страницы: 1 вся ветка

Текущий архив: 2002.04.08;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.009 c
14-22808
Дмитрий_Ч
2002-02-26 17:29
2002.04.08
SOS!!!


14-22844
Zool
2002-02-22 17:08
2002.04.08
Читаем файл...


1-22666
Goblinus
2002-03-26 10:24
2002.04.08
MDI


1-22618
VictorT
2002-03-27 16:29
2002.04.08
Список файлов в конкретной папке (без вложеных)


1-22640
asat
2002-03-27 20:57
2002.04.08
Как прервать цикл?