我有一個通過 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(例如重繪)、LinkFillControlToField 和 BindSourceDB 的屬性和方法,但沒有任何效果對我有用。
我使用在 Windows 10 上運行的 Delphi 10.4 Update 2、Firemonkey Windows 應用程式(32 或 64)。
TIA.,
里卡多
uj5u.com熱心網友回復:
我有同樣的問題。我的資料源是 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();
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/357959.html
