This is what works for me. Just drop a ComboBox on the same form as the StringGrid for each column you need a ComboBox for.
procedure TfrmMain.sgCellsClick(Sender: TObject);
var
nTop, nLeft, nWidth, nHeight : integer;
begin
if ( sgCells.Col = 0 ) then
begin
with cbCol0 do
begin
PositionCB( sgCells, nTop, nLeft, nHeight, nWidth );
Top := nTop;
Left := nLeft;
Width := nWidth;
Height := nHeight;
ItemIndex := Items.IndexOf( sgCells.Cells[ sgCells.Col, sgCells.Row ] );
Visible := True;
ActiveControl := cbCol0;
end;
end
else if ( sgCells.Col = 1 ) then
with cbCol1 do
begin
PositionCB( sgCells, nTop, nLeft, nHeight, nWidth );
Top := nTop;
Left := nLeft;
Width := nWidth;
Height := nHeight;
ItemIndex := Items.IndexOf( sgCells.Cells[ sgCells.Col, sgCells.Row ] );
Visible := True;
ActiveControl := cbCol1;
end;
end
.
.
.
procedure TfrmMain.PositionCB( const sgGrid : TStringGrid; var iTop, iLeft, iHeight, iWidth : integer );
var
i, iStartRow, iStartCol : integer;
begin
with sgGrid do
begin
iStartRow := TopRow;
iStartCol := LeftCol;
iTop := Top;
iLeft := Left;
{ Compute Row Height }
for i := iStartRow to Row do
iTop := iTop + RowHeights[ i ] + GridLineWidth;
{ Compute Col Width }
for i := iStartCol to Col - 1 do
iLeft := iLeft + ColWidths[ i ] + GridLineWidth;
if ( FixedCols > 0 ) then
for i := 0 to FixedCols - 1 do
iLeft := iLeft + ColWidths[ i ] + GridLineWidth;
iTop := iTop + GridLineWidth + 1;
iLeft := iLeft + GridLineWidth + 1;
iHeight := RowHeights[ Row ] + ( GridLineWidth * ( Row - iStartRow ) );
iWidth := ColWidths[ Col ];
end;
end;
I hope this helps.