kalo agan" ingin menampilkan data dari Database ke listview mungking coding yang ane kasih bisa bantu, langsung saja ane kasing listingnya :
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, DB, ADODB, StdCtrls;
type
TForm1 = class(TForm)
ListView1: TListView;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure TampilListview;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.TampilListview;
Begin
try
ListView1.Items.Clear;
with ADOQuery1 do
begin
Close;
SQL.Text := 'select *from country';
Open;
while Not Eof do
begin
with ListView1.Items.Add do
begin
Caption := ADOQuery1.fieldbyName('name').AsString;
SubItems.Add(ADOQuery1.fieldByName('Capital').AsString);
SubItems.Add(ADOQuery1.fieldByName('continent').AsString);
SubItems.Add(ADOQuery1.fieldByName('area').AsString);
SubItems.Add(ADOQuery1.fieldByName('population').AsString);
end;
Next;
end;
end;
except
MessageDlg('Gagal Menampilkan Data !!',mtWarning,[mbOK],0);
end
End;
procedure TForm1.Button1Click(Sender: TObject);
begin
TampilListview
end;
end.
Sekian listing untuk menampilkan data ke Listview dari database.Semoga berhasil...
0 comments:
Post a Comment
Jangan Lupa Memberikan Komentar, Namun Tolong Agar Menggunakan Bahasa Yang BAIK dan SOPAN Terima Kasih...