刚刚试了一下,我的办法完全可行,样例如下:
uses ..., Grids;
Interface
type
TMyGrid = class(TStringGrid)
published
property InplaceEditor
//******
end;
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
MyGrid: TMyGrid;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var p: integer;
begin
p:=MyGrid.InplaceEditor.selStart;
edit1.text:=IntToStr(p);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
MyGrid:=TMyGrid.create(self);
MyGrid.parent:=self;
MyGrid.left:=20;
MyGrid.Top:=100;
MyGrid.Options:=MyGrid.Options + [goEditing];
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
MyGrid.free;
end;
end.
新建一个APP, 加上一个 TButton 和一个 TEdit, 上述程序可以运行。