把form1窗體的stringGrid的某cells[col,row]數據傳到form2後,怎樣把form2處理後的數據返回到form1的stringGrid的cells[col,row]? 請賜教!!

解决方案 »

  1.   

    form1中写
    if form2.domodal()==mrok
    then
    begin
       ///cells[col,row]=form2...........
    end;
      

  2.   

    从form1传到form2时,记录传递的是form1的stringgrid中的哪个cell中的数据,在从form2向回传时,读出记录的cell不就可以了
      

  3.   

    function TForm2.HandleCell(var ACellStr: String);
    变参不就行了
      

  4.   

    //Unit 代码unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, Grids, StdCtrls, Buttons;type
      TForm1 = class(TForm)
        StringGrid1: TStringGrid;
        BitBtn1: TBitBtn;
        procedure FormCreate(Sender: TObject);
        procedure BitBtn1Click(Sender: TObject);
        procedure StringGrid1DblClick(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation
    uses unit2;
    {$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
    var
      i:integer;
    begin
      StringGrid1 .RowCount :=12;
      for i:=1 to 11 do
        begin
          StringGrid1 .RowHeights [i]:=20;
          StringGrid1 .Cells [1,i]:=Inttostr(i);
        end;
    end;procedure TForm1.BitBtn1Click(Sender: TObject);
    var
      Form2:TForm2;
    begin
      Form2:= TForm2 .Create(Owner);
      Form2.Str :=StringGrid1 .Cells [StringGrid1 .Col,StringGrid1 .Row];
      if form2.ShowModal =mrok then
        begin
          StringGrid1 .Cells [StringGrid1 .Col,StringGrid1 .Row]:=Form2 .Str ;    end;  form2.Free;
    end;procedure TForm1.StringGrid1DblClick(Sender: TObject);
    begin
     BitBtn1 .Click ;
    end;end.
      

  5.   

    //Unit2代码unit Unit2;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm2 = class(TForm)
        Button1: TButton;
        Button2: TButton;
        Edit1: TEdit;
      private
        procedure SetStr(const Value: String);
        function GetStr: String;
        { Private declarations }
      public
        { Public declarations }
      published
        property Str:String Read GetStr Write SetStr;
      end;
    implementation{$R *.dfm}{ TForm2 }function TForm2.GetStr: String;
    begin
      Result:=Edit1.text;end;procedure TForm2.SetStr(const Value: String);
    begin
      edit1.text:=Value ;end;end.