希望给我推荐一款适合单据输入的网格控件----不要像dbgrid那样数据绑定,先谢了!!!
   在单击某一网格时,能出现下拉列表框,或弹出用户自定义窗体的那种!!!

解决方案 »

  1.   

    在stringgrid的SelectCell事件中动态计算combobox的位置,把值付给cell
    例:procedure Tfrm_makerep.StringGrid1SelectCell(Sender: TObject; ACol,
      ARow: Integer; var CanSelect: Boolean);begin
           if ComboBox1.Visible then
        begin
            StringGrid1.Cells[3,iRow] := ComboBox1.text;
            ComboBox1.Visible := false;                                    
        end
        else if Combobox2.Visible then                               
        begin                                                          
           StringGrid1.Cells[4,iRow] := ComboBox2.Text;
           ComboBox2.Visible := false;
        end
        else if Edit1.Visible then
        begin
            StringGrid1.Cells[5,iRow] := Edit1.Text;
            Edit1.Visible := false;
        end;
        iCol:=ACol;
        iRow:=ARow;
        if iCount = 0 then
            exit;
          if ACol = 0 then
      begin
        if StringGrid1.Cells[0,ARow]=chr(1) then
          StringGrid1.Cells[0,ARow]:=''
        else
          StringGrid1.Cells[0,ARow]:=chr(1);
      end;
         if ACol = 3 then
        begin
            ComboBox1.Top := StringGrid1.top + (Arow
                            - StringGrid1.TopRow+1)*(StringGrid1.RowHeights[1]+1)+2;
            ComboBox1.ItemIndex:=ComboBox1.Items.IndexOf(StringGrid1.Cells[3,ARow]);
            ComboBox1.Visible := true;
        end
        else if ACol = 4 then
        begin
            ComboBox2.Top := StringGrid1.top + (Arow
                            - StringGrid1.TopRow+1)*(StringGrid1.RowHeights[1]+1)+2;
            ComboBox2.ItemIndex:=ComboBox2.Items.IndexOf(StringGrid1.Cells[4,ARow]);
            //ComboBox2.Text := StringGrid1.Cells[4,ARow];
            ComboBox2.Visible := true;
        end
        else if ACol = 5 then
        begin
            Edit1.Top := StringGrid1.top + (Arow
                            - StringGrid1.TopRow+1)*(StringGrid1.RowHeights[1]+1)+2;        Edit1.Text := StringGrid1.Cells[5,ARow];
            Edit1.Visible := true;
        end;end;