We have experimented with the TBufDataset component in Lazarus and found it (like the less-functional TMemdataset) trickier to use and less reliable than the TClientDataset component in Lazarus. This Free Pascal wiki page was helpful, but more complicated than necessary to enable a school student to get started.
filter the records so that only those matching your criteria are shown in the grid.
Most of the steps make use of the Object Inspector.
Start a new application and select menu item File > Save all.
Save the project as BufDatasetDemo1 and the unit as uBufDatasetDemo1.
Drop onto the form a TBufDataset and TDataSource (Data Access tab), a TDBNavigator and TDBGrid (Data Controls tab) and a CheckBox (Standard tab).
In the Object Inspector, set the Filtered property of BufDataset1 to true and enter Strings for its IndexFieldNames property.
In the Object Inspector click on the triangle to the left of BufDataset1, right click on <unknown collection>: TFieldDefs and select the menu item Add Item.
Change the data type of the new FieldDef to ftString, its name to Strings and its size to 10.
Similarly create a FieldDef named Integers with type ftInteger, Size 4 and Precision 4.
Similarly create a FieldDef named Floats with type ftFloat, Size 8 and Precision 4.
In the Object Inspector, select BufDataset1 for the Dataset property of DataSource1.
BufDataset1 is, of course, the only dataset in the drop-down list.
Similarly, set the DataSource property of DBGrid1 and DBNavigator1 to DataSource1.
Right-click on DBGrid1 in the Object Inspector and select the menu item Edit Columns ... .
Click the + icon three times to add three columns.
Select the FieldName property of the first column to be Strings, the second to be Integers and the third to be Floats.
The column titles will given the same name as the field name, but you can change them if you wish.
Set the Checked property of CheckBox1 to be true and change its Caption property to Filtered.
Set the width of DBGrid1 to be 300 and suitably position it and the other visible components, DBNavigator1 and CheckBox1. Adjust the size of the form.
Double click on the form to create the FormCreate procedure and paste the following code into it between begin and end.
Note that we include the instruction CreateDataset and do not change the value of the Active property of the dataset to true (as we did with the MemDataset in the previous section).
As expected, only the strings beginning with T are shown and they are in alphabetical order.
Uncheck the CheckBox to view all of the records. Confirm that you can navigate through the records, and click on the + icon to add a new row.
Type in the data Five, 5 and 5.6 then click in another row or on the Post (tick) icon to store the changes. Close the application then execute it again.
You should find that your new data has been saved to file and reloaded successfully.
Try editing data and also typing erroneous data into the number columns or a string longer than ten characters into the first column.
The second demo (on the next page) requires the same kind of set-up and has a ComboBox to choose the Sort field, a label, two labelled edit boxes to enter a range for the filter and a button to execute the filter. It transfers the initial (real world) data from arrays to the dataset.