unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, StdCtrls;type
TForm1 = class(TForm)
DBGrid1: TDBGrid;
ComboBox1: TComboBox;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
var
StringList: TStrings;
StringL:TStrings ;
begin StringList := TStringList.Create;
StringL := TStrings.Create ;
try
with StringList do begin
Add('This example uses A string List.');
Add('It is the easiest way to add strings');
Add('to a combobox''s list of strings.');
Add('Always remember TStrings.Create method');
Add('is abstract; So use TStringList.Create');
Add('method instead.'); end;
with StringL do
begin
//Add('1234560');
// Add('147258369');
Add('to a combobox''s list of strings.');
Add('Always remember TStrings.Create method');
end;
DBGrid1.Columns[0].PickList := StringList ;
with ComboBox1 do begin
Width := 210;
Items.Assign(StringList);
ItemIndex := 0;
end;
// end;
finally
StringList.free;
StringL.Free ;
end;
end;
end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, StdCtrls;type
TForm1 = class(TForm)
DBGrid1: TDBGrid;
ComboBox1: TComboBox;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
var
StringList: TStrings;
StringL:TStrings ;
begin StringList := TStringList.Create;
StringL := TStrings.Create ;
try
with StringList do begin
Add('This example uses A string List.');
Add('It is the easiest way to add strings');
Add('to a combobox''s list of strings.');
Add('Always remember TStrings.Create method');
Add('is abstract; So use TStringList.Create');
Add('method instead.'); end;
with StringL do
begin
//Add('1234560');
// Add('147258369');
Add('to a combobox''s list of strings.');
Add('Always remember TStrings.Create method');
end;
DBGrid1.Columns[0].PickList := StringList ;
with ComboBox1 do begin
Width := 210;
Items.Assign(StringList);
ItemIndex := 0;
end;
// end;
finally
StringList.free;
StringL.Free ;
end;
end;
end.
DescriptionEAbstractError is raised when an application tries to call an Object Pascal abstract method. It is also raised at design time when a component with an Object Pascal abstract method is placed on a form.Abstract methods are declared with the abstract directive and must be overridden in descendant classes before an instance object can be created.
with ComboBox1 do begin
Width := 210;
Items.Assign(StringList);
ItemIndex := 0;
end;
// end;
FORM CREATE的时候放在FORM上 VCL都还没创建呢;
但是我只要把
with StringL do
begin
//Add('1234560');
// Add('147258369');
Add('to a combobox''s list of strings.');
Add('Always remember TStrings.Create method');
end;
屏蔽掉,就不会出错,但dbgrid1.column出不来
StringL := TStrings.Create ;
为什么却用的是Tstringlist.create.