Positioning and coloring implementation of DBGRID in Delphi

xiaoxiao2021-03-06  44

Delphi's positioning and coloring implementation of DBGRID 1 Problem In the case of operating the database system, it is found that the data line in the DBGRID control cannot be marked with a significant sign of the current line after positioning to a line (for example Changing the color), finding a lot of information in the past, found that there is no introduction to this content, including some of the color of the dynamic set, etc., is made when the data is initialized, but not in the data source brush The repositioning function, so we will determine this problem. Through the study of Delphi help in the morning, it is slightly smaller. It is now written together and learn together, please advise. 2 solution

First find the TTable and TQuery controls have not found the way to directly locate the data line, and also find the DBGRID nor find a function that can directly locate the data, then I will find it from the class of the data set. After continuous efforts, finally A method found in TDataSet: gotoBookmark, this method enables the record pointer in the current DBGRID to the row you need to specify. After finding this method, the problem only solves half, but also change the color of the data line points to the current pointer, that is, you must use an obvious way to mark the current line (out of the little on dbgrid). Outside the bookmarks) This is clearly implemented in the DBGRID control, there is an event overdrawdatacell in the DBGRID control, and the desired data line can be changed.

The specific use process is as follows: (1) Dynamic positioning data rows / / =================================== ============================ // process name: DyDbgDataLine // author: haitian // date: 2003-02-22 // Function: Automatically move to a row data of this condition in accordance with the user specified by the user to the DBGRID control: // svalue: The value of the row that needs to be moved; // Tab: The corresponding table in DBGRID Data; // DSR: Data source currently required; // Return value: None // Modify record: / / ======================== ================================================= Procedure DydbgDataline (SVALUE: String; Tab: TTable DSR: tdatasource) Var bookmark: TBOOKMARK; begin // Record the current tag of the current mark; Bookmark: = self. Tab.getBookmark; Self. Tab.first; while not self. Tab.eof do beg, tab.eeldbyname ( 'cpbh'). Asstring = Svalue The begin Bookmark: = Self. Tab.getBookmark; Break; End; Self. Tab.next; End; Self. dsr.dataset.gotobookmark (Poinmark); END; Description: Use The table has been bound to the DBGRID binding on the current display interface;

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

New Post(0)