delphi - How to use a TcxCustomDataSource in a TcxExtLookupComboBox? -
I use TxxExtLookupComboBox from Dexxpress and try to apply custom data source. I have set up customdeters in such a way:
processing TMainForm.FormCreate (Sender: TObject); Start fDataSource: = TMyDataSource.Create; CbotestSearch.Properties.View.DataController.CustomDataSource: = fDataSource; End;
TMyDataSource is defined here:
the unit data source; Uses interface classes, IBITI, SUUSUtils, CXSwistadata; Type TSearchItem = Class Private Bold ID: String; Display: string end; TMyDataSource = class (TcxCustomDataSource) Private fSearchList: TList; Protected function GetRecordCount: integer; Override; Function GetValue (ARecordHandle: TcxDataRecordHandle; AItemHandle: TcxDataItemHandle): Variants; Override; Make Public Builders; Destruction of Destruction; Override; Process GetData; End; TMyDataSource.Create the Implementation Maker; Start the heritage; Create; FSearchList: = TList.Create; End; Distributor TMyDataSource.Destroy; Start Free and Neil (FSXL); inherited from; End; Process TMyDataSource.GetData; Var vItem: TSearchItem; Start fSearchList.Clear; VItem: = TSearchItem.Create; VItem.BoldID: = '1000'; VItem.Display: = 'test'; FSearchList.Add (vItem); VItem: = TSearchItem.Create; VItem.BoldID: = '1100'; VItem.Display: = 'test2'; FSearchList.Add (vItem); DataChanged; // Do not do anything as a provider is not the end; Function TMyDataSource.GetRecordCount: Integer; The start / results have never been recorded: = fSearchList.Count; End; Function TMyDataSource.GetValue (ARecordHandle: TcxDataRecordHandle; AItemHandle: TcxDataItemHandle): Variants; Started // has never entered the result: = 'test'; End; End.
The problem is that TMyDataSource.GetValue is never called. How to fix any hint? Here is another hint: If there is a single step in the DataChanged method that GetValue should be called, it looks like this:
Update 1: Process TcxCustomDataSource.DataChanged; If the provider = zero exit then; // code using provider end;
And the provider is zero in this case. But as you are seeing, I have assigned data sources to forms.
cxExtLookupComboBox can only work with DB ~ view. Such views can not accept examples of TcxCustomDataSource objects as a datasource. Therefore, your code will not work :-( There is a suggestion to implement this feature in the future and it has been registered here:
Comments
Post a Comment