Форум: "Основная";
Текущий архив: 2004.10.10;
Скачать: [xml.tar.bz2];
ВнизStringGrid Найти похожие ветки
← →
zokzok (2004-09-23 18:16) [0]когда с грида уходишь на другой компонент, то последняя не fixed ячейка, на которую кликали мышкой закрашивается синим - что это такое? и можно как-нибудь этот цвет убрать, не закрашивая его через canvas
← →
alless (2004-09-23 18:22) [1]Попробуй это:
procedure TForm.sgrDrawCells(Sender: TObject; Col, Row: Longint; Rect: TRect;
State: TGridDrawState);
var
ACol: longint absolute Col;
ARow: longint absolute Row;
Buf: array[byte] of char;
begin
if State = gdFixed then
Exit;
with sgrGrid do begin
Canvas.Font := Font;
Canvas.Font.Color := clWindowText;
Canvas.Brush.Color := clWindow;
Canvas.FillRect(Rect);
StrPCopy(Buf, Cells[ACol,ARow]);
DrawText(Canvas.Handle, Buf, -1, Rect,
DT_SINGLELINE or DT_VCENTER or DT_NOCLIP or DT_LEFT);
end;
end;
← →
Defunct © (2004-09-23 18:31) [2][1] можно немного проще.
Назначьте событие OnDrawCell вашему StringGrid
в обработчике:procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
Var SG: TStringGrid;
Begin
SG := Sender as TStringGrid;
If (ACol = SG.Col) And (ARow = SG.Row) Then
Begin
SG.Canvas.Brush.Color := SG.Color;
SG.Canvas.TextRect( Rect, Rect.Left, Rect.Top, SG.Cells[ACol, ARow]);
End;
End;
← →
Defunct © (2004-09-23 18:32) [3]обработчик [2] можно назначить всем StringGrid"ам в приложении
← →
GanibalLector © (2004-09-23 20:16) [4]Не,мой код самый короткий.Юзай:
procedure TForm1.StringGrid1Exit(Sender: TObject);
var MyG:TGridRect;
begin
MyG.Left:=-1;
StringGrid1.Selection:=MyG;
end;
и все :))
← →
GrayFace © (2004-09-23 20:39) [5]alless (23.09.04 18:22) [1]
Зачем еще один буфер, лишнее копирование - чем строка не угодила?
Зачем все эти переменные? Почемы State только на Fixed проверяется? Кошмар!
В [1] есть 1 плюс (не всегда это плюс) по сравнению с [2] отличаются по действию - в [1] многострочный текст будет в 1 строке, разделенный "||", в [2] - будет видна только первая строка.
Вот нормальный выриант, действующий, как [1]:procedure TForm.sgrDrawCells(Sender: TObject; ACol, ARow: Longint; Rect: TRect; State: TGridDrawState);
begin
if State <> [] then Exit;
with sender as TStringGrid do
begin
Canvas.Font := Font;
Canvas.Brush.Color := Color;
Canvas.FillRect(Rect);// это, может быть, не нужно
DrawText(Canvas.Handle, PChar(Cells[ACol,ARow]), -1, Rect,
DT_SINGLELINE or DT_VCENTER or DT_NOCLIP or DT_LEFT);
end;
end;
Возможно надо убрать DT_NOCLIP.
Можно навесить на любой StringGrid, как и [2].
← →
GrayFace © (2004-09-23 20:49) [6]Еще надо DT_NOPREFIX.
Страницы: 1 вся ветка
Форум: "Основная";
Текущий архив: 2004.10.10;
Скачать: [xml.tar.bz2];
Память: 0.46 MB
Время: 0.042 c