find fejl i stringgrid !
hej til alle.er der nogen der kan se fejlen ved dette.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, StdCtrls, Db, DBTables, ExtCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
stringrid: TStringGrid;
Button3: TButton;
Table1: TTable;
Panel2: TPanel;
stringrid1: TStringGrid;
Button1: TButton;
DataSource1: TDataSource;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure stringrid1Click(Sender: TObject);
private
nytabel: ttable;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
Table1.open;
Table1.First;
stringrid.Cells [0, 0] := Table1.IndexFieldNames;
stringrid.Rowcount:=1;
while not table1.Eof do begin
stringrid.Cells [0, stringrid.RowCount - 1] :=IntToStr (stringrid.RowCount -1);
stringrid.Cells [1, stringrid.RowCount - 1] :=table1.Fields [0] .AsString;
stringrid.Cells [2, stringrid.RowCount - 1] :=table1.Fields [1] .AsString;
stringrid.Cells [3, stringrid.RowCount - 1] :=table1.Fields [2] .AsString;
stringrid.Cells [4, stringrid.RowCount - 1] :=table1.Fields [3] .AsString;
stringrid.RowCount := stringrid.RowCount + 1;
table1.next;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
nytabel:= ttable.create (nil);
nytabel.databasename:='MyDB';
nytabel.tablename:='category.DB';
nytabel.open;
nytabel.first;
stringrid1.Cells [0, 0] := Table1.IndexFieldNames;
stringrid1.Rowcount:=1;
while not table1.Eof do begin
stringrid1.Cells [0, stringrid1.RowCount - 1] :=IntToStr (stringrid1.RowCount -1);
stringrid1.Cells [1, stringrid1.RowCount - 1] :=nytabel.Fields [0] .AsString;
stringrid1.Cells [2, stringrid1.RowCount - 1] :=nytabel.Fields [1] .AsString;
stringrid1.Cells [3, stringrid1.RowCount - 1] :=nytabel.Fields [2] .AsString;
stringrid1.Cells [4, stringrid1.RowCount - 1] :=nytabel.Fields [3] .AsString;
stringrid1.RowCount := stringrid1.RowCount + 1;
nytabel.next;
//nytabel.free;
end;
end;
procedure TForm1.stringrid1Click(Sender: TObject);
begin
end;
end.
