以下函数运行的时候提示,tmpstrlist  may not have been initialized,该如何改正?  procedure MoveStringGridData(Grid: TStringGrid; Sou,Des :Integer );
  var
    TmpStrList: TStringList ;
    K : Integer ;
  begin
    try
      TmpStrList :=TStringList.Create() ;
      TmpStrList.Clear ;
      for K := 0 to Grid.ColCount -1 do
        TmpStrList.Add(Grid.Cells[K,Sou]) ;
      Grid.Rows [Sou] := Grid.Rows [Des] ;
      for K := 0 to Grid.ColCount -1 do
        Grid.Cells [K,Des]:= TmpStrList.Strings[K] ;
    finally
      TmpStrList.Free ;
    end;
  end;

解决方案 »

  1.   


          TmpStrList :=TStringList.Create() ;
        try//here you  need try.....
          TmpStrList.Clear ;
          for K := 0 to Grid.ColCount -1 do
            TmpStrList.Add(Grid.Cells[K,Sou]) ;
          Grid.Rows [Sou] := Grid.Rows [Des] ;
          for K := 0 to Grid.ColCount -1 do
            Grid.Cells [K,Des]:= TmpStrList.Strings[K] ;
        finally
          TmpStrList.Free ;
        end;
      

  2.   

    Grid.Rows[Sou].Clear;
    Grid.Rows[Sou].AddStrings(Grid.Row[Sou]);