http://www.delphi2007.net/DelphiVCL/html/delphi_20061220150258245.html
在dbcombobox中可不可以
显示值 提交值
男 1
女 0
在选择时显示的是显示值,可是提交post时,提交的是int型的0或1;
其中dbcombobox只联接一个数据源!不用在listdatastore中联接其它数据源来对应提交值!
(注:只联接一个数据源!)
没有。只能用dblookupcombobox
用数据集字段的事件
procedure TForm1.ADOQuery1SexGetText(Sender: TField; var Text: string;
DisplayText: Boolean);
begin
case Sender.AsInteger of
0: Text := '女';
1: Text := '男';
end;
end;
procedure TForm1.ADOQuery1SexSetText(Sender: TField; const Text: string);
begin
if Text = '女' then
Sender.Value := 0
else if Text = '男' then
Sender.Value := 1;
end;
多谢了!老大啊,你答了我发的两个贴的同一个题!我的分也只好给你加一次了!在那个贴子中已经结了!
本文探讨了在Delphi中使用DBComboBox控件时如何实现在界面显示性别文字(男/女),而在后台提交整数型性别标识(1/0)。通过自定义事件处理,详细介绍了如何设置和获取字段文本,确保数据的一致性和正确性。

被折叠的 条评论
为什么被折叠?



