delphi中Query+ataSource+DBGrid现在我要用什么函数才能在DBGrid中查找和定位某一条记录呢?

解决方案 »

  1.   

    TDatesetfunction Locate(const KeyFields: string; const KeyValues: Variant; Options: TLocateOptions): Boolean; virtual;
      

  2.   

    通过SQL语句或QUREY的过滤找到合适的记录
    DBGRID自己会转到该记录的
      

  3.   

    function Locate(const KeyFields: string; const KeyValues: Variant; Options: TLocateOptions): Boolean; virtual;
      

  4.   

    TBDEDataSet.LocateSearches the dataset for a specified record and makes that record the current record.function Locate(const KeyFields: String; const KeyValues: Variant; Options: TLocateOptions): Boolean;DescriptionCall Locate to search a dataset for a specific record and position the cursor on it.KeyFields is a string containing a semicolon-delimited list of field names on which to search.KeyValues is a variant array containing the values to match in the key fields. If KeyFields lists a single field, KeyValues specifies the value for that field on the desired record. To specify multiple search values, pass a variant array as KeyValues, or construct a variant array on the fly using the VarArrayOf routine. For example:with CustTable do
      Locate('Company;Contact;Phone', VarArrayOf(['Sight Diver', 'P', '408-431-1000']), [loPartialKey]);Options is a set that optionally specifies additional search latitude when searching on string fields. If Options contains the loCaseInsensitive setting, then Locate ignores case when matching fields. If Options contains the loPartialKey setting, then Locate allows partial-string matching on strings in KeyValues. If Options is an empty set, or if the KeyFields property does not include any string fields, Options is ignored.Locate returns True if it finds a matching record, and makes that record the current one. Otherwise Locate returns False.Locate uses the fastest possible method to locate matching records. If the search fields in KeyFields are indexed and the index is compatible with the specified search options, Locate uses the index. Otherwise Locate creates a filter for the search.
      

  5.   

    先设好query的sql, 再用Locate
      

  6.   

    function Locate(const KeyFields: string; const KeyValues: Variant; Options: TLocateOptions): Boolean; virtual;
      

  7.   

    吧Query定位就行了 用locate 或查询时定位它 或写个循环找找