0

我正在拼命地尝试在其 PK 与 TDBAdvGrid 中的第 0 列相关联的记录上进行定位。我拥有的 TMS 组件包版本是 6.8.something。我在带有 Delphi XE 1 的 Win7x64 中使用它。 PageMode 已关闭,因为我需要在客户端级别进行排序和分组(目前没有后端数据库,只有处于离线模式的客户端数据集)。

我的定位代码是这样的:

procedure TMainFrm.EditAction;
var ItemID : Integer;
    ItemIDStr: String;
begin
  // With PageMode set to false(which we need), the dataset is not synchronized.
  //ItemID := GetActionGrid.Columns[ 0 ].Field.AsInteger;
  ItemIDStr := GetActionGrid.Cells[ 0,GetActionGrid.SelectedRow[ 0 ] ];
  ItemID := StrToIntDef( ItemIDStr ,-1 );
//  GetActionGrid.Fields[ 0 ].AsInteger;
  If DMMain.CLNActions.Locate( 'ITEM_ID',ItemID,[] ) Then
    CreateApplicationForm( TActionFrm, True );
end;

但它不起作用,因为 ItemIDStr 总是返回一个空字符串。我现在真的很缺乏想法。

建议?

谢谢!

4

1 回答 1

0
function TFrameDBGrid1.GrFindValInCol(FldName, FldVal : String) : boolean; //search value in a certain column of the grid
var
   StartCell:TPoint;
   FindParams: TFindParams;
   rv:TPoint;
   CurrCol: integer;
  I: Integer;
const CResultInvalidInt=-1;
begin
  Result := false;
  StartCell.x := CResultInvalidInt;
  StartCell.y := CResultInvalidInt;
  CurrCol := GetColumnIndexOfField(FldName);
  grdGlobal.FindCol := CurrCol;
  FindParams := [fnMatchRegular, fnFindInPresetCol];
  rv:=grdGlobal.Find(StartCell, FldVal, FindParams);
  Result:= (rv.x <> CResultInvalidInt) and (rv.y <> CResultInvalidInt);
  if Result then
    if grdGlobal.Row <> rv.y then
      grdGlobal.Row := rv.y;
end;
于 2013-06-10T14:21:14.527 回答