我希望用下拉列表实现如下功能:
下拉列表中出现 “男”,“女”,在数据库中存储的是1,0,
我没有存储“男”,“女”的码表,
请问如何实现?

解决方案 »

  1.   

    在TField.OnGetText和OnSetText中写代码,如:procedure TForm1.Table1SexGetText(Sender: TField; var Text: String;
      DisplayText: Boolean);
    begin
      if Sender.AsString = '1' then Text := '男'
      else Text := '女';
    end;procedure TForm1.Table1SexSetText(Sender: TField; const Text: String);
    begin
      if Text = '男' then Sender.AsString := '1'
      else Sender.AsString := '0'
    end;—————————————————————————————————
    宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
    —————————————————————————————————
      

  2.   

    试试这样,看看合不合你意:将这个值作为 ComboBox1.ItemIndex 选择后的值返回给数据库。你如果希望希望男返回1,女返回0,就先输入女,后输男。这样返回的值就是你所期待的。