請問在stringgrid裡面
如何控制:
序號為奇數的行,要限制他的數量只能輸入負數
序號為偶數的行,要限制他的數量只能輸入正數

解决方案 »

  1.   

    可以在StringGrid的SetEditText事件中加以判断
    procedure TForm1.StringGrid1SetEditText(Sender: TObject; ACol,
      ARow: Integer; const Value: String);
    begin
      if (ARow Mod 2 = 0) then begin
        if StrToIntDef(Value, 0) < 0 then
          ShowMessage('请输入正数');
      end
      else begin
        if StrToIntDef(Value, 0) > 0 then
          ShowMessage('请输入负数');
      end;
    end;
      

  2.   

    procedure TForm1.StringGrid1SetEditText(Sender: TObject; ACol,
      ARow: Integer; const Value: String);
    begin
      if (ARow Mod 2 = 0) then begin
        if StrToIntDef(Value, 0) < 0 then
          ShowMessage('请输入正数');
      end
      else begin
        if StrToIntDef(Value, 0) > 0 then
          ShowMessage('请输入负数');
      end;
    end;楼上正解。
      

  3.   

    chris_mao 问下你,你发的贴子,怎么字体有颜色。