RAD Studio VCL Reference
|
Specifies a set of bookmarks for all the records in the dataset that correspond to rows selected in the grid.
property SelectedRows: TBookmarkList;
__property TBookmarkList SelectedRows;
Use the properties and methods of the TBookmarkList object returned by SelectedRows to
Determine the number of rows in the grid that are selected.
Determine whether the current record in the dataset is selected.
Determine whether a particular record in the dataset is selected.
Delete all selected rows from the dataset.
SelectedRows is only meaningful when the Options property includes dgRowSelect and dgMultiSelect.
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;
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|