Delphi 在 AdoTable 中插入 Firemonkey ComboBox
Delphi Firemonkey ComboBox insert in AdoTable
所以,我一直在组合框的两个 table 之间使用 LiveBindings 来获取外键的 ID 和描述(具有 Item.LookupData 和 Item.text 属性)并将键分配给另一个 table 中具有 SelectedValue 属性的字段。我猜这工作正常,但我正在使用自定义 dbnavigator 控件来制作 "register form"。
我正在使用这样的方法来制作插入物:adotablealuno.FieldValues['Nome']:=editnomeAluno.Text;
但是我找不到如何以这种方式使用组合框,我已经尝试了 ItemIndex 和 Selected 属性,但是 none 这项工作(顺便说一句,我正在使用 Access DB)。为此,我如何在 ComboBox 中使用我的外键?
其实我已经在说这个了 很久都没有好的答案。我找到了我目前正在使用的出路。至少我知道我会得到可靠的数据。
您需要以类似的方式处理 LinkFillControlToField
link 的 OnFillingListItem
事件,并将 ID 号存储在 ComboBox
项目中。我为此目的使用 Tag
属性 虽然它实际上并不好。
procedure TForm1.LinkFillControlToField1FillingListItem(Sender: TObject;
const AEditor: IBindListEditorItem);
begin
(AEditor.CurrentObject as TListBoxItem).Tag :=
YourLookuptable.FieldByName('id').AsInteger;
end;
然后从 ListBox1.Selected.Tag 中获取项目 ID。可以通过 ComboBox1.Selected.Text
.
访问文本值
追加。
你做了一个相似的 LinkFillControlToField
link。
然后你 select 这个 link 并为 link 创建一个 OnFillingListItem
事件处理程序(select 对象检查器中的事件选项卡并双击 OnFillingListItem
ComboBox)。事件处理程序(空过程)将出现。它将被命名为 TForm1.LinkFillControlToField1FillingListItem(...
然后你编写代码将 id 属性 设置为项目的标签。
所以,我一直在组合框的两个 table 之间使用 LiveBindings 来获取外键的 ID 和描述(具有 Item.LookupData 和 Item.text 属性)并将键分配给另一个 table 中具有 SelectedValue 属性的字段。我猜这工作正常,但我正在使用自定义 dbnavigator 控件来制作 "register form"。
我正在使用这样的方法来制作插入物:adotablealuno.FieldValues['Nome']:=editnomeAluno.Text;
但是我找不到如何以这种方式使用组合框,我已经尝试了 ItemIndex 和 Selected 属性,但是 none 这项工作(顺便说一句,我正在使用 Access DB)。为此,我如何在 ComboBox 中使用我的外键?
其实我已经在说这个了 LinkFillControlToField
link 的 OnFillingListItem
事件,并将 ID 号存储在 ComboBox
项目中。我为此目的使用 Tag
属性 虽然它实际上并不好。
procedure TForm1.LinkFillControlToField1FillingListItem(Sender: TObject;
const AEditor: IBindListEditorItem);
begin
(AEditor.CurrentObject as TListBoxItem).Tag :=
YourLookuptable.FieldByName('id').AsInteger;
end;
然后从 ListBox1.Selected.Tag 中获取项目 ID。可以通过 ComboBox1.Selected.Text
.
追加。
你做了一个相似的 LinkFillControlToField
link。
然后你 select 这个 link 并为 link 创建一个 OnFillingListItem
事件处理程序(select 对象检查器中的事件选项卡并双击 OnFillingListItem
ComboBox)。事件处理程序(空过程)将出现。它将被命名为 TForm1.LinkFillControlToField1FillingListItem(...
然后你编写代码将 id 属性 设置为项目的标签。