2
votes

The OnDrawCell event gives me a "Rect" record so that I know where the real pixel coordinates are:

OnDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);

On the other hand, the OnSelectCell only gives me the row/col coordinates.

OnSelectCell(Sender: TObject; ACol, ARow: Integer; var CanSelect: Boolean);

How do I translate the row/col to pixel coordinates?

I need those because I need to create a ComboBox at runtime to cover the whole selected cell, but only when the cell is selected. I know how to do everything, but I do not know how to get the coordinates (right now, I am just creating the combo at 0,0 of the parent tStringGrid).

I am using Delphi7, but I think it is a general question and not related to the Delphi version.

PS: I am aware that there are plenty of commercial and freeware components that implement a combobox inside a cell, but I cannot and/or do not want to use them.

Thank you

1

1 Answers

4
votes

You can determine cell screen coordinates using CellRect method

P.S. Have you ever tried to integrate controls into StringGrid?
When you meet problems with controls (having grid as Parent) behavior, look at this topic