Board index » delphi » Filling Lists
Mark Reichert
![]() Delphi Developer |
Filling Lists2007-01-20 05:42:28 AM delphi42 Thanks to help from TeamB members I came up with this for filling a Listbox. The names have been changed to generics, because I am uncomfortable posting our actual code in a public forum. Where Items is an ObjectList created in the DataModule OnCreate and freed in the OnDestroy. procedure TdmB.GetList(TheStrings: TStrings); var Item : TItem; begin TheStrings.Clear; With ibsql1 do begin With Transaction do If Not InTransaction Then StartTransaction; Try ParamByName('ID').AsInteger := dmA.ID; ExecQuery; While not Eof do begin Item := TItem.Create(FieldByName('irID').AsTrimString); Items.Add(Item); TheStrings.AddObject(FieldByName('NAME').AsTrimString, Item); Next; end; Close; Finally With Transaction do If InTransaction Then Commit; End; end; end; Only then did it occur to me that I was tying my GUI to my DataModule, which is what I have been working to avoid in single record code. The first step is to maintain a separate list in the object layer. I could even use the above, if it is alright for the data modules to see classes in the object layer. Are there any good examples anywhere showing connecting up datamodules to an object layer with the populating of lists. |