procedure TForm1.FormCreate(Sender: TObject);
begin
Table1.Open;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
sr: TSearchRec;
FileAttrs: Integer;
begin
if FindFirst('c:*.*', FileAttrs, sr) = 0 then
begin
repeat
Table1.Append;
Table1.FieldByName('Name').AsString := sr.Name;
until FindNext(sr) <> 0;
FindClose(sr);
end;
end;
그렇다면
먼저 db를 만드시고
unit Unit1;
interface
uses
Windows, Messages, Classes, SysUtils, Graphics, Controls, StdCtrls, Forms,
Dialogs, DBCtrls, DB, DBGrids, DBTables, Grids, ExtCtrls;
type
TForm1 = class(TForm)
Table1Name: TStringField;
DBGrid1: TDBGrid;
DBNavigator: TDBNavigator;
Panel1: TPanel;
DataSource1: TDataSource;
Panel2: TPanel;
Table1: TTable;
Table1No: TAutoIncField;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
var
GogakNo : LongInt;
procedure TForm1.FormCreate(Sender: TObject);
begin
Table1.Open;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
sr: TSearchRec;
FileAttrs: Integer;
begin
if FindFirst('c:*.*', FileAttrs, sr) = 0 then
begin
repeat
Table1.Append;
Table1.FieldByName('Name').AsString := sr.Name;
until FindNext(sr) <> 0;
FindClose(sr);
end;
end;
end.
라고 해 보세요.