【问题标题】:Listbox does not show the changes made to the Dataset列表框不显示对数据集所做的更改
【发布时间】:2021-12-14 03:39:38
【问题描述】:

我有一个通过 LiveBindings 连接到 ClientDataset 的 FMX ComboBox。一切正常,直到我需要从 ClientDataset 过滤数据。应用过滤器后,ComboBox.Items 和 ComboBox.ListItems 就ok了,即是过滤后的ClientDataset中包含的数据。但 ComboBox 列表框显示的数据始终相同:第一次显示列表框时 ClientDataset 包含的数据。

procedure TForm14.Button1Click(Sender: TObject);
begin
  LinkFillControlToField1.Active := False;
  ClientDataset1.Filter := 'TYPE = ''N''';
  Clientdataset1.Filtered := not ClientDataset1.Filtered;
  // Deactivate and Reactivate the link is necessary to refresh the data
  LinkFillControlToField1.Active := True;
end;

在该代码中,我将过滤器更改为 ClientDataset 并停用 LinkFillControlToField 并在应用过滤器后再次激活它以刷新数据。它与 TListBox 和其他控件一起工作没有问题,但与 TComboBox 不兼容,尽管 ComboBox.Items 和 ComboBox.ListItems 确实包含正确的数据,但它不是组合框列表框中显示的数据。

有没有办法解决这个问题,使用 LiveBindings ?我已经查找了 ComboBox(例如 Repaint)、LinkFillControlToField 和 BindSourceDB 的属性和方法,但对我没有任何帮助。

我使用在 Windows 10 上运行的 Delphi 10.4 Update 2、Firemonkey Windows 应用程序(32 或 64)。

TIA.,

里卡多

【问题讨论】:

    标签: delphi combobox firemonkey livebindings


    【解决方案1】:

    我遇到了同样的问题。我的数据源是 TFireDAC TQuery。我提交了对查询中包含的 parma 的更改。 我对我的问题的解决方案是插入该行以明确清除项目列表。

    if (SCM != NULL && SCM->qrySession->Active) {
        SCM->qrySession->DisableControls();
        // remove all the strings held in the combobox
        // note cmbSessionList->Clear() doesn't work here.
        cmbSessionList->Items->Clear();
        SCM->qrySession->Close();
        // ASSIGN PARAM to display or hide CLOSED sessions
        SCM->qrySession->ParamByName("HIDECLOSED")->AsBoolean = fHideClosedSessions;
        SCM->qrySession->Prepare();
        SCM->qrySession->Open();
        SCM->qrySession->EnableControls();
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-10-22
      • 1970-01-01
      • 2015-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-18
      相关资源
      最近更新 更多