Question and Answer Database FAQ4439D.txt — Creating a custom TInplaceEdit for TDBGrid Category :Database/VCL Platform :All Windows Product :All32Bit, Question: How can I customize the cell editor for a TDBGrid? Answer: You should create a custom TInPlaceEdit for use within Grids. Following is an example component: unit CustomEditorGrid; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, Grids, DBGrids; type TMyInplaceEdit = class(TInplaceEdit) public procedure DblClick; override; end; TCustomEditorGrid = class(TDBGrid) private { Private declarations } protected { Protected declarations } function CreateEditor: TInplaceEdit; override; public { Public declarations } published { Published declarations } end; procedure Register; implementation const SomeDefaultValue = 'Default Value'; procedure Register; begin RegisterComponents('Custom', [TCustomEditorGrid]); end; { TCustomEditorGrid } function TCustomEditorGrid.CreateEditor: TInplaceEdit; begin Result := TMyInplaceEdit.Create(Self); end; { TMyInplaceEdit } procedure TMyInplaceEdit.DblClick; begin inherited DblClick; if (Text = '') then Text := SomeDefaultValue; end; end. 4/1/99 11:32:33 AM
Last Modified: 01-SEP-99