Wikia

Delphi Programming

TDBGrid Class

2,918pages on
this wiki
Talk0
This page is intended as a supplement to the official documentation on Delphi programming. CodeGear is in the process of putting the Delphi documentation on the Web. Once they have done so, this page will link to the relevant page in the official documentation.
Stub
This article is a stub.
Please help enhance the Delphi Programming Wiki by expanding it.
Info
see the VCL Documentation Guidelines for an overview on doc pages

UnitEdit

HierarchyEdit

DescriptionEdit

(Please provide a description in your own words. It is illegal to use the wording from the Delphi Help.)

Technical CommentsEdit

(Known issues / Documentation clarifications / Things to be aware of)

ExamplesEdit

procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
var 
  veri: AnsiString;
  i: Integer;
begin
  if (gdSelected in state) then 
  begin
    DBGrid1.Canvas.Brush.Color := $00A00000;  
    DbGrid1.Canvas.Font.Color := clWhite; 
  end 
  else
  begin
    if (DBGrid1.DataSource.DataSet.RecNo mod 2) =0 then
      DBGrid1.Canvas.Brush.Color := clGray
    else 
      DBGrid1.Canvas.Brush.Color := clTeal;
    end;
    DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
    if not (Column.Field.DataType = null) then
    begin
      if TDBGrid(Sender).Canvas.TextWidth(Column.Field.asString) > (Rect.Right-Rect.Left) then
      begin
        veri := Column.Field.asString;
        while TDBGrid(Sender).Canvas.TextWidth(Veri) > (Rect.Right-Rect.Left) do
          delete(Veri, Length(Veri), 1); 
          for i := 1 to 3 do 
          begin
            delete(Veri, Length(Veri), 1); 
          end;
          veri := veri + '...';
          TDBGrid(Sender).Canvas.FillRect(Rect); 
          TDBGrid(Sender).Canvas.TextOut( Rect.Left+1, Rect.Top+1, Veri );
        end;
      end;
    end;

See AlsoEdit

(Please provide links to items specifically related to this item.)

User Comments/TipsEdit

(Please leave your name with your comment.)

Around Wikia's network

Random Wiki