在Delphi7编程时,用了Advstringgrid控件,在StringGrid2GetEditorType事件中,给第3列增加了控件
if ACol = 3 then
begin
aEditor := edEditBtn;
end;
我的想法是:即可以通过按钮调取数据列表,然后选择数据,也可以在输入数据后,系统自动判断输入数据的合合法性,如果合法则通过,不合法则提示不合法,并清空刚才输入数据。
我在StringGrid2SetEditText事件中,写入如下语句,但是不生效,刚才输入的数据还在,我现在就想怎么可以把数据清空。
stringgrid2.cells[3,ARow]:='';
stringgrid2.Refresh;
全部的代码是
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, BaseGrid, AdvGrid;
type
TForm1 = class(TForm)
StringGrid2: TAdvStringGrid;
procedure StringGrid2GetEditorType(Sender: TObject; ACol,
ARow: Integer; var AEditor: TEditorType);
procedure StringGrid2SetEditText(Sender: TObject; ACol, ARow: Integer;
const Value: String);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.StringGrid2GetEditorType(Sender: TObject; ACol,
ARow: Integer; var AEditor: TEditorType);
begin
if ACol = 3 then
begin
aEditor := edEditBtn;
end;
end;
procedure TForm1.StringGrid2SetEditText(Sender: TObject; ACol,
ARow: Integer; const Value: String);
begin
stringgrid2.cells[3,ARow]:='bbbbb';
stringgrid2.Refresh;
end;
end.