Карта сайта Kansoftware
НОВОСТИУСЛУГИРЕШЕНИЯКОНТАКТЫ
Разработка программного обеспечения
KANSoftWare

StringGrid, выделить фиксированные строки

Delphi , Компоненты и Классы , TStringGrid и TDrawGrid

StringGrid, выделить фиксированные строки

Code:
unit Unit1;
 
interface
 
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids;
 
type
TForm1 = class(TForm)
   StringGrid1: TStringGrid;
   procedure FormCreate(Sender: TObject);
   procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
     Rect: TRect; State: TGridDrawState);
end;
 
var
Form1: TForm1;
 
implementation
 
{$R *.dfm}
 
procedure TForm1.FormCreate(Sender: TObject);
var
C, R: Integer;
begin
for C := 0 to StringGrid1.ColCount - 1 do
begin
   for R := 0 to StringGrid1.RowCount - 1 do
   begin
     if (C < StringGrid1.FixedCols) or
        (R < StringGrid1.FixedRows) then
       StringGrid1.Cells[C, R] := Format('Fixed Cell (%dx%xd)', [C, R])
     else
       StringGrid1.Cells[C, R] := Format('Cell (%dx%d)', [C, R]);
   end;
end;
end;
 
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
I: Integer;
begin
with StringGrid1 do
   if gdFixed in State then
   begin
     Canvas.FillRect(Rect);
     InflateRect(Rect, -2, 0);
     if (ACol = Col) or (ARow = Row) then
       Canvas.Font.Style := [fsBold]
     else
       Canvas.Font.Style := [];
     DrawText(Canvas.Handle,
       PChar(Cells[ACol, ARow]), -1, Rect,
       DT_SINGLELINE or DT_VCENTER);
   end else begin
     Rect := CellRect(ACol, 0);
     for I := 1 to FixedRows - 1 do
       with CellRect(ACol, I) do
         Inc(Rect.Bottom, Bottom - Top);
     InvalidateRect(Handle, @Rect, True);
 
     Rect := CellRect(0, ARow);
     for I := 1 to FixedCols - 1 do
       with CellRect(I, ARow) do
         Inc(Rect.Right, Right - Left);
     InvalidateRect(Handle, @Rect, True);
   end;
end;
 
end.
Взято из http://forum.sources.ru
Автор: Smike

Статья StringGrid, выделить фиксированные строки раздела Компоненты и Классы TStringGrid и TDrawGrid может быть полезна для разработчиков на Delphi и FreePascal.


Комментарии и вопросы


Ваше мнение или вопрос к статье в виде простого текста (Tag <a href=... Disabled). Все комментарии модерируются, модератор оставляет за собой право удалить непонравившейся ему комментарий.

заголовок

e-mail

Ваше имя

Сообщение

Введите код




Материалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта.



:: Главная :: TStringGrid и TDrawGrid ::


реклама



©KANSoftWare (разработка программного обеспечения, создание программ, создание интерактивных сайтов), 2007
Top.Mail.Ru Rambler's Top100

Время компиляции файла: 2024-04-24 22:55:34
2024-04-25 17:48:11/0.0067310333251953/2