在很多单据录入时,常用这样的方法,还有下拉列表是如何在表格中创建的呢?请各位帮帮我,最好是写出完整的代码。
在此多谢了!!!

解决方案 »

  1.   

    代码:
    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控件不会随着移动!
      

  2.   

    楼主:建议还是用第三方控件,如DBGridEh,它能满足你的要求(不用自己写代码)。
      

  3.   

    哈哈!上面的那位英雄说的对!用DBGridEh的确不错!
      

  4.   

    DBGridEh是在ehlib23控件包中吗?我下了一个编译安装后但在VCL里没出现?????