Treatment of multiple records in TDBGRID controls using bookmark functions

zhaozj2021-02-17  50

Delphi's TDBGRID control master is used to handle data tables, and there is a DGMultISElect in its properties. If this property is set to true, you can select multiple records (available Ctrl mouse left keys to select multiple records). There are several ways to select a few of the following processes, compared to the more simple order: clear all the selected records available DBGRID1.SelectedRows.clear statements; delete all selected records available dbgrid1.selectedRows.delete statements. However, if you want to select other information of the record, for example, in a single-single window, the content of the number of records, such as all selected names, is it? This is to make the bookmark function, the next is a process in one program written by the author, and it is used to display the multiple records selected by the user in another window (the author uses Delphi4) for reference. Procedure getSelectedRecord (DataSet: TDataSet; BookmarkList: TBookmarkList; strings: tstrings); file: // The parameters in this process are: data sheets, field names, bookmarks, files for saving the selected field content: // String (used to pass the content to the TLIST control in another separate form) VARI: Integer; BM: TBOOKMARK; Beginstrings.clear; with DataSet Do BegindisableControls; bm: = getBookmark; tryfile: // Each The selected record has a bookmark sign, which provides conditions for I: = 0 to BookmarkList.count - 1 do beginbookmark: = BookmarkList [i]; strings.add (Dataset.Findfield (Fieldname) .sstring) ; FINALLYGOTOKMARK (BM); FreeBookmark (BM); EnableControls; End; end; end; call example: getSelectedRecord (Table1, 'Name', dbgrid1.selectedRows, Form2.ListBox1.Items

转载请注明原文地址:https://www.9cbs.com/read-30299.html

New Post(0)