原创  将DBGrid 当前列定位到指定的字段上 收藏

//--------------------------------------------------------------------------------
// 功能:将 DbGrid 当前列定位到某字段上。
// 参数: pDbGrid:TDbGrid;        DBGrid
//              pcFieldName : string    数据表字段名,字段名不区分大小写
// 返回:当表字段在 DBGrid 中存在时,返回表字段所在的列的序号,首序号为0
//             否则,返回 -1
// 引用:GetDbGridColumnIndex(  );
// 例如:SetDbGridColumn( DbGrid1, 'Price' );
//--------------------------------------------------------------------------------
Function SetDbGridColumn( pDbGrid:TDbGrid; pcFieldName : string  ):integer;
var nCol : integer ;
begin
  Result := GetDbGridColumnIndex( pDbGrid, pcFieldName );
  if nCol >= 0 then pDbGrid.SelectedIndex := Result ;
end;


例子:

    SetDbGridColumn( DbGrid1, 'Price'  );
    将DbGrid1的当前列定位到字段Price上。

发表于 @ 2005年07月18日 11:49:00 | 评论( loading... ) | 编辑| 举报| 收藏

旧一篇:Dbgrid 中表字段所在的列序号 | 新一篇:修改记录字段值时错误Row cannot be located for updating的解决方法

  • 发表评论
  • 评论内容:
  •  
Copyright © ForestK
Powered by CSDN Blog