Components for Delphi and C++ Builder.

Go to Russian forum
Go to EhLib.com
It is currently 24 Apr 2024, 20:21

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: 24 Sep 2019, 19:38 
Offline

Joined: 24 Sep 2013, 12:18
Posts: 21
Hi,

I have done all the setup of the cellbutton of the first column of the DBGridEh.
Column.CellButtons[0].Visible := True;
Column.CellButtons[0].Enabled := True;
Column.CellButtons[0].Pressable := True;
Column.CellButtons[0].HorzPlacement := ebhpLeftEh;
Column.CellButtons[0].DrawBackTime := edbtAlwaysEh;

Unfortunately the column's cell button is not visible but is working.
When I click on the left side of the column's cell the OnClick event of the cellbutton is fired.

How can I change the background color of the cellbutton to make it visible?

The DBGrideh has a OnDrawColumCell event that change the color of some cells of the DBGridEh.

Thank you for any help.


Top
 Profile  
 
PostPosted: 25 Sep 2019, 19:35 
Offline

Joined: 08 May 2014, 18:06
Posts: 663
Hello

I don’t see your code, but I think that in the OnDrawColumCell event handle you paint over the button.
If you want to change the background or font color, use the OnGetCellParams event.

_________________
Best regards
EhLib Support Team


Top
 Profile  
 
PostPosted: 26 Sep 2019, 16:29 
Offline

Joined: 24 Sep 2013, 12:18
Posts: 21
Hi,

I have used the OnDrawColumnCell event of the DBGridEh to solve the problem of the invisible cellbutton.

Below is my solution for this problem:

Code:
procedure TForm.DbGridEhDrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumnEh;
                                                                                                                                State: TGridDrawState);
{Put on the form a TImageList component with two bitmaps: [-] and [+].
Each bitmap has height = 9 and width = 9.
My TImageList component is named imgCellBtn.}

  var
    ImgIdx : Byte; // Inform the bitmap index of the imgCellBtn : TImageList

    CellBtnRect,
    ValueRect : TRect;
    CellBtnState : Integer;

    DBGrid : TDBGridEh;

begin
  DBGrid := Sender as TDBGridEh;

  with DBGrid do
    begin
      {The CellButton is on the Column with DataCol = 0.}
      if (DataCol = 0) then
        begin
          CellBtnRect := Rect;
          CellBtnRect.Left := Rect.Left + 1;
          CellBtnRect.Top  := Rect.Top + 3;
          CellBtnRect.Height := 9;
          CellBtnRect.Width  := 9;
          Canvas.FillRect(Rect);
          CellBtnState := DFC_BUTTON or DFCS_BUTTONPUSH or DFCS_PUSHED or DFCS_FLAT;
          DrawFrameControl(Canvas.Handle, CellBtnRect, DFC_BUTTON, CellBtnState);
   
          if (gdFocused in State) then
            begin
               {pnlValues is the panel with the values of some fields that I want to show when the cellbutton is pressed.}
              if (pnlValues.Visible) then
                ImgIdx := 0 // [-]
              else
                ImgIdx := 1; // [+]
            end
          else
            ImgIdx := 1; // [+]
   
          {imgCellBtn is  a TImageList with two 9x9 bitmaps: [-] and [+].}
          imgCellBtn.Draw(Canvas, CellBtnRect.Left, CellBtnRect.Top, ImgIdx);
   
          {The value of the Field of DataCol = 0 is drawn.}
          ValueRect := Rect;
          ValueRect.Left := CellBtnRect.Left + CellBtnRect.Width + 1;
          ValueRect.Height := Rect.Height;
          ValueRect.Width := Rect.Width - ValueRect.Left - 1;
   
          DBGrid.DefaultDrawColumnCell(ValueRect, DataCol, Column, State);
        end;
   end;
end;


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group