<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns="http://www.w3.org/TR/REC-html40" xmlns:o =
"urn:schemas-microsoft-com:office:office" xmlns:w =
"urn:schemas-microsoft-com:office:word"><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2180" name=GENERATOR>
<STYLE>@font-face {
        font-family: Verdana;
}
@page Section1 {size: 612.0pt 792.0pt; margin: 72.0pt 90.0pt 72.0pt 90.0pt; }
P.MsoNormal {
        FONT-SIZE: 10pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: Verdana
}
LI.MsoNormal {
        FONT-SIZE: 10pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: Verdana
}
DIV.MsoNormal {
        FONT-SIZE: 10pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: Verdana
}
H1 {
        FONT-SIZE: 16pt; MARGIN: 12pt 0cm 3pt; FONT-FAMILY: Verdana; TEXT-ALIGN: center
}
H2 {
        FONT-SIZE: 14pt; MARGIN: 12pt 0cm 3pt; FONT-STYLE: italic; FONT-FAMILY: Verdana
}
A:link {
        COLOR: blue; TEXT-DECORATION: underline
}
SPAN.MsoHyperlink {
        COLOR: blue; TEXT-DECORATION: underline
}
A:visited {
        COLOR: purple; TEXT-DECORATION: underline
}
SPAN.MsoHyperlinkFollowed {
        COLOR: purple; TEXT-DECORATION: underline
}
SPAN.EmailStyle17 {
        COLOR: windowtext; FONT-FAMILY: Arial; mso-style-type: personal-compose
}
DIV.Section1 {
        page: Section1
}
</STYLE>
</HEAD>
<BODY lang=EN-US vLink=purple link=blue>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff size=2>Insert
the rows into the dataset that is connected to the grid.</FONT></SPAN></DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff size=2>This
is only D2005 compatible...</FONT></SPAN></DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff
size=2>======= unit ==============</FONT></SPAN></DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff size=2>unit
Unit55;</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff
size=2>interface</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff
size=2>uses<BR> Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms,<BR> Dialogs, DB, Grids, DBGrids, DBClient,
StdCtrls;</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff
size=2>type<BR> TForm55 = class(TForm)<BR> DataSource1:
TDataSource;<BR> ClientDataSet1:
TClientDataSet;<BR> DBGrid1: TDBGrid;<BR>
Button1: TButton;<BR> Button2: TButton;<BR>
procedure Button2Click(Sender: TObject);<BR> procedure
Button1Click(Sender: TObject);<BR> private<BR> { Private
declarations }<BR> public<BR> { Public declarations
}<BR> end;</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff
size=2>var<BR> Form55: TForm55;</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff
size=2>implementation</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff size=2>{$R
*.dfm}</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff
size=2>procedure TForm55.Button1Click(Sender: TObject);<BR>var<BR> lList:
TStringList;<BR> lStr: String;<BR> lCnt: Integer;<BR>begin<BR>
lList := TStringList.Create;<BR> try<BR>
lList.Add('Item0');<BR>
lList.Add('Item1');<BR>
lList.Add('Item2');<BR>
lList.Add('Item3');<BR>
lList.Add('Item4');<BR>
lList.Add('Item5');<BR>
ClientDataSet1.FieldDefs.Add('FieldOne', ftInteger, 0,
False);<BR> ClientDataSet1.FieldDefs.Add('FieldTwo', ftString,
10, False);<BR>
ClientDataSet1.CreateDataSet;<BR> ClientDataSet1.Active :=
True;<BR> lCnt := 0;<BR> for lStr in lList
do<BR> begin<BR>
ClientDataSet1.Append;<BR>
ClientDataSet1.Fields[0].AsInteger := lCnt;<BR>
ClientDataSet1.Fields[1].AsString := lStr;<BR>
ClientDataSet1.Post;<BR>
inc(lCnt);<BR> end;<BR> finally<BR>
FreeAndNil(lList);<BR> end;<BR>end;</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff
size=2>procedure TForm55.Button2Click(Sender: TObject);<BR>begin<BR>
ClientDataSet1.Active := False;<BR> close;<BR>end;</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff
size=2>end.<BR></FONT></SPAN></DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff size=2>======
form ==============</FONT></SPAN></DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff size=2>object
Form55: TForm55<BR> Left = 0<BR> Top = 0<BR> Width =
391<BR> Height = 270<BR> Caption = 'Form55'<BR> Color =
clBtnFace<BR> Font.Charset = DEFAULT_CHARSET<BR> Font.Color =
clWindowText<BR> Font.Height = -11<BR> Font.Name =
'Tahoma'<BR> Font.Style = []<BR> OldCreateOrder = False<BR>
PixelsPerInch = 96<BR> TextHeight = 13<BR> object DBGrid1:
TDBGrid<BR> Left = 8<BR> Top =
40<BR> Width = 369<BR> Height =
193<BR> DataSource = DataSource1<BR>
TabOrder = 0<BR> TitleFont.Charset =
DEFAULT_CHARSET<BR> TitleFont.Color =
clWindowText<BR> TitleFont.Height = -11<BR>
TitleFont.Name = 'Tahoma'<BR> TitleFont.Style = []<BR>
end<BR> object Button1: TButton<BR> Left =
8<BR> Top = 8<BR> Width =
75<BR> Height = 25<BR> Caption =
'Execute'<BR> TabOrder = 1<BR> OnClick =
Button1Click<BR> end<BR> object Button2:
TButton<BR> Left = 304<BR> Top =
8<BR> Width = 75<BR> Height =
25<BR> Caption = 'Close'<BR> TabOrder =
2<BR> OnClick = Button2Click<BR> end<BR> object
DataSource1: TDataSource<BR> DataSet =
ClientDataSet1<BR> Left = 184<BR> Top =
120<BR> end<BR> object ClientDataSet1:
TClientDataSet<BR> Aggregates = <><BR>
Params = <><BR> Left = 192<BR> Top =
128<BR> end<BR>end</FONT></SPAN></DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff
size=2>cheers,</FONT></SPAN></DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff
size=2>JED</DIV></FONT></SPAN>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B> tracey
[mailto:tracey@logis.co.nz]<BR><B>Sent:</B> 10 February 2005 8:56
AM<BR><B>To:</B> NZ Borland Developers Group - Delphi List<BR><B>Subject:</B>
[DUG] Dynamically fill DBGrid from TStringlist<BR><BR></FONT></DIV>
<DIV class=Section1>
<P class=MsoNormal><FONT face=Arial size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Is this possible? How does
one dynamically load rows into a DBGrid from
code?<o:p></o:p></SPAN></FONT></P></DIV></BLOCKQUOTE></BODY></HTML>