http://www.delphi2007.net/DelphiVCL/html/delphi_20061220150549244.html
在dbcombobox中可不可以
显示值 提交值
男 1
女 0
在选择时显示的是显示值,可是提交post时,提交的是int型的0或1;
其中dbcombobox只联接一个数据源!不用在listdatastore中联接其它数据源来对应提交值!
(注:只联接一个数据源!)
不行吧`~即使提交了`~哪你显示的时候呢?
用数据集字段的事件
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控件时如何实现在界面上显示文本值,而在提交数据时发送整数值的问题。通过数据集字段的GetText和SetText事件,实现了显示值与提交值之间的转换。
261

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



