0

Bonjour. I am using kdbgrid from KControls for lazarus. 1- When i add this :

procedure TForm1.KDBGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  R: TRect; State: TKGridDrawState);

begin
    if (aCol <> 1) or (aRow = 0) then begin
        Exit;
    end;
      if (aCol=2) and (aRow > 1) then begin
        KDBGrid1.CellRect(aCol, ARow,R);
        R.Left := R.Right - (R.Bottom - R.Top);
        Button3.BoundsRect := R;
        KDBGrid1.Editor.Assign(Button3);
      end;
end

my dbgrid does't show correctly.

so i can't add any buttons to the cells of the grid or images in a permanent way. I read the help (kgrid_manual.pdf) but i didn't find any thin.

thanks a lot .

my dbgrid

  • So what do you expect to happen in an empty `OnDrawCell` event handler? You need to put a bit more effort into your question. F.ex. what do you really want to do, or to happen? Why did you consider to use the event in the first place? What do you mean with adding buttons or images? Btw. we don't provide help "as quickly as possible ...", after all we are just unpaid volunteers :) – Tom Brunberg Oct 12 '20 at 13:32
  • Why do you tag Delphi if you use Lazarus? Lazarus is different. – fpiette Oct 12 '20 at 14:11
  • Normally, kdbgrid (KControls ) can work on delphi to. – Tester-dev Oct 12 '20 at 16:34
  • If you use the `OnDrawCell` event, you're expected to provide code that actually affects the appearance of the cell. You do absolutely nothing to draw anything, and then fail to call DefaultDrawCell at the end. Why would you expect it to show correctly when you do all that you can to make it not show correctly? `OnDrawCell` is for use to do **exactly** what it says to do, which is to draw the cell. – Ken White Oct 12 '20 at 19:28
  • You obviously need to get a wider and deeper understanding of the grid component, so I suggest you download the demo projects for `kgrid` and `kdbgrid` from [github repository](https://github.com/kryslt/KControls/tree/master/demos) and study those examples before you proceed. – Tom Brunberg Oct 13 '20 at 09:38
  • You only need to deal with the `OnDrawCell` event if you need to change how the data appears in the cells. Don't focus on the `OnDrawCell` event yet. If you want to know how to add components to the grid, read the manual again, chapter 3 in total. It describes how you can implement an edit control. The same principle goes for a dropdown controls etc. – Tom Brunberg Oct 13 '20 at 10:00
  • I don't want the button to appear when i click , I want it to be always in the cell.ok, the demo is a very good idea . – Tester-dev Oct 13 '20 at 14:39

0 Answers0