我想如果输入框内的内容是"男",我就在数据库中写入1,如果是"女",写入2
这个在OnSetText事件中,应该怎么写?

解决方案 »

  1.   

    在Table的beforepost前if table1.fieldbyname('sex').asstring='难' then table1.fieldbyname('sex').asstring:='1'
      

  2.   

    var
      s: string;
    begin
      if Sender.IsNull then
      begin
        Text := '-';
        exit;
      end;
      
      case Sender.Value of
      1: Text := '男';
      2: Text := '女';
      else
      end;
    end;
      

  3.   

    procedure TMasterDetail.adMasterSexSetText(Sender: TField;
      const Text: String);
    begin
      if Text='男' then
        Sender.Value:=1
      else if Text='女' then
        Sender.Value:=2;
    end;