代码: procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer; var CanSelect: Boolean); begin if acol=1 then begin combobox1.Left :=stringgrid1.left+stringgrid1.CellRect(ACol,arow).Left; combobox1.Top :=stringgrid1.Top+stringgrid1.CellRect(ACol,arow).top; Combobox1.Width:=stringgrid1.CellRect(stringgrid1.Col,stringgrid1.row).Right-stringgrid1.CellRect(stringgrid1.Col,stringgrid1.row).Left; combobox1.Height:=stringgrid1.CellRect(stringgrid1.Col,stringgrid1.row).Bottom-stringgrid1.CellRect(stringgrid1.Col,stringgrid1.row).Top; combobox1.Visible :=true; end else combobox1.Visible :=false; end; 注意:这只是实现把combobox控件嵌入到stringgrid控件中,但部分效果要你自己写一点代码进去,特别stringgrid控件的横滚条移动时,combobox控件不会随着移动!
procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
begin
if acol=1 then
begin
combobox1.Left :=stringgrid1.left+stringgrid1.CellRect(ACol,arow).Left;
combobox1.Top :=stringgrid1.Top+stringgrid1.CellRect(ACol,arow).top;
Combobox1.Width:=stringgrid1.CellRect(stringgrid1.Col,stringgrid1.row).Right-stringgrid1.CellRect(stringgrid1.Col,stringgrid1.row).Left;
combobox1.Height:=stringgrid1.CellRect(stringgrid1.Col,stringgrid1.row).Bottom-stringgrid1.CellRect(stringgrid1.Col,stringgrid1.row).Top;
combobox1.Visible :=true;
end else
combobox1.Visible :=false;
end;
注意:这只是实现把combobox控件嵌入到stringgrid控件中,但部分效果要你自己写一点代码进去,特别stringgrid控件的横滚条移动时,combobox控件不会随着移动!