Jump to content
СофтФорум - всё о компьютерах и не только

компонент DBGrid


hint
 Share

Recommended Posts

Возможно ли в компоненте DBGrid установить чередующийся цвет строк?

И ище как прописать так чтобы строка допустим с просроченной датой выделялась цветом

спасиба...

Link to comment
Share on other sites

Процедура OnDrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState).

Пример использования (под себя переделаешь, думаю):

procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;

  Field: TField; State: TGridDrawState);

begin

  if (Sender as TDBGrid).DataSource.DataSet.FieldByName('Extend').AsString =

    '@' then

    with (Sender as TDBGrid).Canvas do

      begin

        FillRect(Rect);

      // SET THE FONT STYLE

      Font.Color:= clRed;

      // DRAW THE CELL RIGHT ALIGNED FOR FLOATS + OFFSET

        if (Field.DataType = ftFloat) then

          TextOut(Rect.Right - TextWidth(Field.AsString) - 3,

            Rect.Top + 3, Field.AsString)

      // OTHERWISE DRAW THE CELL LEFT ALIGHED + OFFSET

        else

          TextOut(Rect.Left + 2, Rect.Top + 3, Field.AsString);

      end;

end;

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...