RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TBookmarkList.Items Property

Provides indexed access to the bookmarks for marked records in the dataset.

Pascal
property Items [Index: Integer]: TBookmarkStr;
C++
__property TBookmarkStr Items[int Index];

Use Items to obtain a bookmark string from the set maintained by the TBookmarkList object. Each bookmark string represents a single record in the dataset of the associated DBGrid. Bookmark strings can be compared with other bookmark strings to determine relative position within the database, and used to position the dataset on an arbitrary record. The Index parameter indicates the index of the bookmark, where 0 is the index of the first bookmark, 1 is the index of the second bookmark, and so on. 

Use Items with the Count property to iterate through all of the bookmarks in the list.

Note: Bookmarks in the bookmark list are not automatically deleted when records in the dataset are deleted. As a result, some bookmarks in the Items array may become invalid. Call the Refresh method to delete invalid bookmarks from the Items array.
 

Delphi Examples: 

 

{
The following example copies the selected rows in a db grid
to a list box.  Set the db grid Options dgRowSelect,
dgAlwaysShowSelection and dgMultiSelect to True.  Make a
multiple selecton using the CNTL key.  This example requires
a TDataSet associated with a TDataSource and a TDBGrid.}
procedure TForm1.Button2Click(Sender: TObject);
var
  i, j: Integer;
  s: string;
begin
  if DBGrid2.SelectedRows.Count>0 then
    with DBGrid2.DataSource.DataSet do
      for i:=0 to DBGrid2.SelectedRows.Count-1 do
      begin
        GotoBookmark(pointer(DBGrid2.SelectedRows.Items[i]));
        for j := 0 to FieldCount-1 do
        begin
          if (j>0) then s:=s+', ';
          s:=s+Fields[j].AsString;
        end;
        Listbox1.Items.Add(s);
        s:= '';
      end;
end;

 

Count 

Clear 

Find 

Refresh 

operator_sb

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!