LCL: db-aware combobox that scrolls the dataset lazarus / 16-Databases ---------------------------------------------------------------------- edgen · 2019-04-16 12:15 Hi! I need a component that allows user to scroll the dataset like DBGrid does. I need this behavior to change content of the detail grid. It should use small area of the window, so I think it will be great if it's a dropdown box. Could anyone advise such existing component or I should write a new one? Thanks! ---------------------------------------------------------------------- madref · 2019-04-17 05:12 Something like this? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var    CB_Seizoen: TDBLookupComboBox;    DS_Straffen: TDataSource;    DS_Seizoen: TDataSource;    TQ_Straffen: TSQLQuery;    TQ_Seizoen: TSQLQuery;    // These are alle present on your form. procedure TForm_RapportStraffenOverzicht.FormShow(Sender: TObject);var cSQL: string;begin  cSQL := 'SELECT Seizoen AS Sei_ID, tbl_Seizoenen.Sei_Periode, Sei_Letter FROM qry_Overzicht_Evaluaties ' +          'INNER JOIN tbl_Seizoenen ON tbl_Seizoenen.SEI_ID = qry_Overzicht_Evaluaties.Seizoen ' +          'GROUP BY Seizoen ' +        'UNION SELECT 0, "(All)" As Sei_Periode, "ZZ" ' +          'FROM tbl_Seizoenen ' +          'ORDER BY Sei_Letter DESC;';  TQ_Seizoen.DataBase := Form_RefereeMain.Connect_RefereeDB;  TQ_Seizoen.SQL.Text := cSQL;  TQ_Seizoen.Active := True;  // setup TDBLookupCombobox  CB_Seizoen.ScrollListDataset := True;  CB_Seizoen.ListSource := DS_Seizoen;  CB_Seizoen.ListField := 'SEI_Periode';  CB_Seizoen.KeyField := 'SEI_ID';  CB_Seizoen.KeyValue := Form_RefereeMain.BepaalHuidigSeizoen; // Spring naar de actieve seizoen  cSQL := 'SELECT RS_ID, RS_Wed_ID, RS_Naam AS Name, RS_NIJB_ID AS [Union No.], RS_Funktie AS Function, ' +          'CASE WHEN RS_Straf=1 THEN "x" ELSE NULL END AS GMP, ' +          'CASE WHEN RS_Straf=2 THEN "x" ELSE NULL END AS MP, ' +          'CASE WHEN RS_Straf=3 THEN "x" ELSE NULL END AS Inc, ' +          'Team, StrFTime(' + SingleQuotedStr ('%d-%m-%Y') + ', Datum) AS Date, ' +        'StrFTime(' + SingleQuotedStr ('%H:%M') + ', Tijd) AS Time, ' +        'RS_Team, Datum, Tijd, Seizoen, qry_Teams.Divisie, ' +        'StrFTime(' + SingleQuotedStr ('%d-%m-%Y') + ', RS_Datum_Verstuurd) AS [Report Send] ' +          'FROM tbl_Rapport_Straffen ' +          'INNER JOIN qry_Overzicht_Wedstrijden ON qry_Overzicht_Wedstrijden.Wed_ID = tbl_Rapport_Straffen.RS_Wed_ID ' +          'INNER JOIN qry_Teams on qry_Teams.Team_ID = tbl_Rapport_Straffen.RS_Team ' +          'WHERE ((Seizoen=:Sei_ID) OR :Sei_ID=0) ' +          'ORDER BY Datum DESC, TIJD DESC, Team ASC, Name ASC';  TQ_Straffen.DataBase := Form_RefereeMain.Connect_RefereeDB;  TQ_Straffen.SQL.Text := cSQL;  TQ_Straffen.Params.ParamByName('Sei_ID').AsInteger := Form_RefereeMain.BepaalHuidigSeizoen;  TQ_Straffen.Active := True;end; procedure TForm_RapportStraffenOverzicht.CB_SeizoenSelect(Sender: TObject);begin  if not TQ_Straffen.Active then exit;  TQ_Straffen.Active := False;  TQ_Straffen.Params.ParamByName('Sei_ID').AsInteger := CB_Seizoen.KeyValue;  TQ_Straffen.Active := True;end;     // CB_SeizoenChange  In the attachment you see how big the combobox is. ---------------------------------------------------------------------- Mike.Cornflake · 2019-04-17 09:02 See also: http://wiki.freepascal.org/TDBLookupComboBox ---------------------------------------------------------------------- Thaddy · 2019-04-17 09:26 Unless the TdbComboBox has "virtual" capabilities, all that is suggested here is futile in the sense that it only applies to very small tables. ---------------------------------------------------------------------- edgen · 2019-04-17 09:55 Quote from: madref on April 17, 2019, 07:12:05 amSomething like this? Thanks! It's good enough! I've just missed ScrollListDataSet property. ---------------------------------------------------------------------- edgen · 2019-04-17 10:01 Quote from: Thaddy on April 17, 2019, 11:26:46 amUnless the TdbComboBox has "virtual" capabilities, all that is suggested here is futile in the sense that it only applies to very small tables. Sure. The solution with combobox is suitable only for small datasets (or well-filtered). I think if the dataset contains more than 10-20 records it will be uncomfortable for the user to select record such way. ---------------------------------------------------------------------- Thaddy · 2019-04-17 10:36 Very small means less than 100-500 on most machines. 500 counts as a small table in the sense that it is easy to keep in memory. ---------------------------------------------------------------------- edgen · 2019-04-17 10:58 I wrote 10-20 from the UX side. Technically it's easy to keep several thousands of records in memory. But if the lookup table contains 1000 records there are two ways (IMHO, of course): - it's design error. - it's complicated distionary and it needs more complex control to choose a record.