unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids,DBGrids, StdCtrls, DB, DBTables;
type
TMyDBGrid=Class(TDBGrid)
Public
property InplaceEditor;
end;
TForm1 = class(TForm)
DBGrid1: TDBGrid;
Edit1: TEdit;
Table1: TTable;
DataSource1: TDataSource;
procedure FormCreate(Sender: TObject);
procedure StringGrid1KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure DBGrid1CellClick(Column: TColumn);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
DBGrid1.EditorMode:=True;
end;
procedure TForm1.StringGrid1KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
Edit1.Text:=TMyDBGrid(DBGrid1).InplaceEditor.Text;
end;
procedure TForm1.DBGrid1CellClick(Column: TColumn);
begin
if TMyDBGrid(DBGrid1).InplaceEditor<>nil then
Edit1.Text:=DBGrid1.SelectedField.DisplayText;
end;
end.