WEB开发网
开发学院软件开发Delphi 处理数据栅格的编辑框 阅读

处理数据栅格的编辑框

 2006-02-04 13:37:09 来源:WEB开发网   
核心提示:///Begin Sourcefunction GetDBGridEdit(mDBGrid: TDBGrid): TEdit;var I: Integer;begin Result := nil; if not Assigned(mDBGrid) then Exit; if not mDBGrid.Editor

///////Begin Source
function GetDBGridEdit(mDBGrid: TDBGrid): TEdit;
var
  I: Integer;
begin
  Result := nil;
  if not Assigned(mDBGrid) then Exit;
  if not mDBGrid.EditorMode then begin
   mDBGrid.EditorMode := True;
   mDBGrid.EditorMode := False;
  end;
  with mDBGrid do for I := 0 to PRed(ComponentCount) do
   if Components[I] is TCustomEdit then begin
    Result := TEdit(Components[I]);
    Break;
   end;
end; { GetDBGridEdit }

function GetDBGridEditText(mDBGrid: TDBGrid): string;
var
  vEdit: TEdit;
begin
  vEdit := GetDBGridEdit(mDBGrid);
  if Assigned(vEdit) then
   Result := vEdit.Text
  else Result := '';
end; { GetDBGridEditText }
///////End Source

///////Begin Demo
procedure TForm1.DBGrid1Enter(Sender: TObject);
var
  vEdit: TEdit;
begin
  vEdit := GetDBGridEdit(TDBGrid(Sender));
  if Assigned(vEdit) then vEdit.Color := clYellow;
end;

procedure TForm1.DBGrid1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  Caption := GetDBGridEditText(TDBGrid(Sender));
end;
///////End Demo

Tags:处理 数据 栅格

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接