Handling the edit box of data grids

zhaozj2021-02-08  230

(* // Title: Handling the data grid Edit: Example Add Focus color; get the field text design that has not been submitted to the data set: Zswang Date: 2002-03-31 Support: wjhu111@21cn.com // * )

/// Begin Sourcefunction 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 the beginning: = TEDIT (Components [i]); Break; end; end; {getDBGridIt}

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 demoProcedure TFORM1.DBGRID1ENTER (Sender: TOBJECT); var vedit: tedit; begin vedit: = getDbGridEdit (TDBGRID (sender)); if Assigned (venit) Then versure;

Procedure tForm1.dbgrid1keyup (Sender: Tobject; var key: word; shift: tshiftState); begin caption: = getDBGridEditText (TDBGRID (sender)); end; /// end demo

转载请注明原文地址:https://www.9cbs.com/read-3367.html

New Post(0)