怎么控制stringgird里限定某一行某一列只能输入一个字符?

解决方案 »

  1.   

    OnSetEditText事件中写
    procedure TForm1.StringGrid1SetEditText(Sender: TObject; ACol,
      ARow: Integer; const Value: String);
    begin
      if (ACol=1) and (ARow=1) and (Length(StringGrid1.Cells[ACol,ARow])>1) then  
        StringGrid1.Cells[2,1] :=StringGrid1.Cells[2,1][1];
    end;
      

  2.   

    OnSetEditText事件中写
    procedure TForm1.StringGrid1SetEditText(Sender: TObject; ACol,
      ARow: Integer; const Value: String);
    begin
      if (ACol=1) and (ARow=1) and (Length(StringGrid1.Cells[ACol,ARow])>1) then  
        StringGrid1.Cells[2,1] :=StringGrid1.Cells[2,1][1];
    end;
      

  3.   

    为什么程序运行到 StringGrid1.Cells[2,1] :=StringGrid1.Cells[2,1][1];
    时会出错!
    错误提示:Access violation at address 0045D02f in module!
    怎么办呀?急!