Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Базы";
Текущий архив: 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
1-22718
Yuri_V
2002-03-26 11:00
2002.04.08
Как передать в процедуру имя формы?


3-22527
diww
2002-03-14 12:35
2002.04.08
Выполнение запроса


3-22530
Sergey-ZZZ
2002-03-04 19:12
2002.04.08
FastReport245


1-22731
Surprising
2002-03-26 21:22
2002.04.08
Не выделение ячейки в StringGrid


3-22534
Incha
2002-03-14 15:12
2002.04.08
Срочно нужна помощь.





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский