扩展了一个StringGrid 为名为CustomStrinGrid
发现在stringGrid中procedure TForm1.stringGridKeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  Memo1.Lines.Add(stringGrid.Cells[1,1]);
end;在KeyUp时stringGrid.Cells[1,1]的值就已经写入到了内部的TStrings中我在CustomStrinGrid中同样也定义了一个 A:TStrings变量 ,
我希望在StringGrid在写入的同时也将值写入到自己定义的变量A中,不知道该如何实现?

解决方案 »

  1.   


    procedure TForm1.stringGridKeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin
      CustomStrinGrid1.A:=StringGrid1.Cols[1];     
      Memo1.Lines.Add(stringGrid.Cells[1,1]);
    end;上面是你给定了行值和列值为1,我觉得你写在KeyUp事件里不大好。不如写在SetEditText事件中procedure TForm1.StringGrid1SetEditText(Sender: TObject; ACol,
      ARow: Integer; const Value: String);
    begin
      CustomStrinGrid1.A:=StringGrid1.Cols[acol];
      showmessage('stringgrid:'+StringGrid1.Cols[acol].Strings[arow]);
      showmessage('customstringgrid:'+CustomStrinGrid1.A.Strings[arow]);
      Memo1.Lines.Add(stringGrid.Cells[1,1]);
    end;不知道这样是不是想要的。
      

  2.   

    其实现在最想知道的就是 stringGrid是怎样在按键弹起的瞬间将单元格的值加入TStrings的
      

  3.   

    IDE中的代码看了就知道了。下班。呵呵