参考如下: 全局变量:iMyRow1,iMyCol1 procedure TFrm_InD.MyStringGrid1DrawCell1(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); begin if (Col = 5) then begin Combobox1.Visible := true ; SetCombobox(StringGrid1,Combobox1); end else if (not bCmm1) then Combobox1.Visible := false ; end;procedure TFrm_InD.SetCombobox(SG:Tstringgrid;Cbb:TCombobox); var MyRect :TRect ; begin with SG do begin MyRect := CellRect(iMyCol1,iMyRow1) ; Cbb.SetBounds(MyRect.Left + Left + 1,MyRect.Top+Top+2, MyRect.Right - MyRect.Left,MyRect.Bottom - MyRect.Top); Cbb.Text := Cells[iMyCol1,iMyRow1]; Cbb.SetFocus ; end end;
全局变量:iMyRow1,iMyCol1
procedure TFrm_InD.MyStringGrid1DrawCell1(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
begin
if (Col = 5) then
begin
Combobox1.Visible := true ;
SetCombobox(StringGrid1,Combobox1);
end
else if (not bCmm1) then Combobox1.Visible := false ;
end;procedure TFrm_InD.SetCombobox(SG:Tstringgrid;Cbb:TCombobox);
var MyRect :TRect ;
begin
with SG do
begin
MyRect := CellRect(iMyCol1,iMyRow1) ;
Cbb.SetBounds(MyRect.Left + Left + 1,MyRect.Top+Top+2,
MyRect.Right - MyRect.Left,MyRect.Bottom - MyRect.Top);
Cbb.Text := Cells[iMyCol1,iMyRow1];
Cbb.SetFocus ;
end
end;