處理數(shù)據(jù)柵格的編輯框
發(fā)表時間:2024-02-25 來源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要](*//標(biāo)題:處理數(shù)據(jù)網(wǎng)格的編輯框說明:示例添加焦點顏色;獲取還沒有提交到數(shù)據(jù)集的字段文本設(shè)計:Zswang日期:2002-03-31支持:wjhu111@21cn.com//*)///////Begin Sourcefunction GetDBGridEdit(mDBGrid: TDBGrid)...
(*//
標(biāo)題:處理數(shù)據(jù)網(wǎng)格的編輯框
說明:示例添加焦點顏色;獲取還沒有提交到數(shù)據(jù)集的字段文本
設(shè)計:Zswang
日期:2002-03-31
支持:wjhu111@21cn.com
//*)
///////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