<!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>&nbsp;</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>&nbsp;</DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff 
size=2>=======&nbsp; unit ==============</FONT></SPAN></DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff size=2>unit 
Unit55;</FONT></SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff 
size=2>interface</FONT></SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff 
size=2>uses<BR>&nbsp; Windows, Messages, SysUtils, Variants, Classes, Graphics, 
Controls, Forms,<BR>&nbsp; Dialogs, DB, Grids, DBGrids, DBClient, 
StdCtrls;</FONT></SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff 
size=2>type<BR>&nbsp; TForm55 = class(TForm)<BR>&nbsp;&nbsp;&nbsp; DataSource1: 
TDataSource;<BR>&nbsp;&nbsp;&nbsp; ClientDataSet1: 
TClientDataSet;<BR>&nbsp;&nbsp;&nbsp; DBGrid1: TDBGrid;<BR>&nbsp;&nbsp;&nbsp; 
Button1: TButton;<BR>&nbsp;&nbsp;&nbsp; Button2: TButton;<BR>&nbsp;&nbsp;&nbsp; 
procedure Button2Click(Sender: TObject);<BR>&nbsp;&nbsp;&nbsp; procedure 
Button1Click(Sender: TObject);<BR>&nbsp; private<BR>&nbsp;&nbsp;&nbsp; { Private 
declarations }<BR>&nbsp; public<BR>&nbsp;&nbsp;&nbsp; { Public declarations 
}<BR>&nbsp; end;</FONT></SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff 
size=2>var<BR>&nbsp; Form55: TForm55;</FONT></SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff 
size=2>implementation</FONT></SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff size=2>{$R 
*.dfm}</FONT></SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff 
size=2>procedure TForm55.Button1Click(Sender: TObject);<BR>var<BR>&nbsp; lList: 
TStringList;<BR>&nbsp; lStr: String;<BR>&nbsp; lCnt: Integer;<BR>begin<BR>&nbsp; 
lList := TStringList.Create;<BR>&nbsp; try<BR>&nbsp;&nbsp;&nbsp; 
lList.Add('Item0');<BR>&nbsp;&nbsp;&nbsp; 
lList.Add('Item1');<BR>&nbsp;&nbsp;&nbsp; 
lList.Add('Item2');<BR>&nbsp;&nbsp;&nbsp; 
lList.Add('Item3');<BR>&nbsp;&nbsp;&nbsp; 
lList.Add('Item4');<BR>&nbsp;&nbsp;&nbsp; 
lList.Add('Item5');<BR>&nbsp;&nbsp;&nbsp; 
ClientDataSet1.FieldDefs.Add('FieldOne', ftInteger, 0, 
False);<BR>&nbsp;&nbsp;&nbsp; ClientDataSet1.FieldDefs.Add('FieldTwo', ftString, 
10, False);<BR>&nbsp;&nbsp;&nbsp; 
ClientDataSet1.CreateDataSet;<BR>&nbsp;&nbsp;&nbsp; ClientDataSet1.Active := 
True;<BR>&nbsp;&nbsp;&nbsp; lCnt := 0;<BR>&nbsp;&nbsp;&nbsp; for lStr in lList 
do<BR>&nbsp;&nbsp;&nbsp; begin<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
ClientDataSet1.Append;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
ClientDataSet1.Fields[0].AsInteger := lCnt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
ClientDataSet1.Fields[1].AsString := lStr;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
ClientDataSet1.Post;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
inc(lCnt);<BR>&nbsp;&nbsp;&nbsp; end;<BR>&nbsp; finally<BR>&nbsp;&nbsp;&nbsp; 
FreeAndNil(lList);<BR>&nbsp; end;<BR>end;</FONT></SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff 
size=2>procedure TForm55.Button2Click(Sender: TObject);<BR>begin<BR>&nbsp; 
ClientDataSet1.Active := False;<BR>&nbsp; close;<BR>end;</FONT></SPAN></DIV>
<DIV>&nbsp;</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>&nbsp;</DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff size=2>object 
Form55: TForm55<BR>&nbsp; Left = 0<BR>&nbsp; Top = 0<BR>&nbsp; Width = 
391<BR>&nbsp; Height = 270<BR>&nbsp; Caption = 'Form55'<BR>&nbsp; Color = 
clBtnFace<BR>&nbsp; Font.Charset = DEFAULT_CHARSET<BR>&nbsp; Font.Color = 
clWindowText<BR>&nbsp; Font.Height = -11<BR>&nbsp; Font.Name = 
'Tahoma'<BR>&nbsp; Font.Style = []<BR>&nbsp; OldCreateOrder = False<BR>&nbsp; 
PixelsPerInch = 96<BR>&nbsp; TextHeight = 13<BR>&nbsp; object DBGrid1: 
TDBGrid<BR>&nbsp;&nbsp;&nbsp; Left = 8<BR>&nbsp;&nbsp;&nbsp; Top = 
40<BR>&nbsp;&nbsp;&nbsp; Width = 369<BR>&nbsp;&nbsp;&nbsp; Height = 
193<BR>&nbsp;&nbsp;&nbsp; DataSource = DataSource1<BR>&nbsp;&nbsp;&nbsp; 
TabOrder = 0<BR>&nbsp;&nbsp;&nbsp; TitleFont.Charset = 
DEFAULT_CHARSET<BR>&nbsp;&nbsp;&nbsp; TitleFont.Color = 
clWindowText<BR>&nbsp;&nbsp;&nbsp; TitleFont.Height = -11<BR>&nbsp;&nbsp;&nbsp; 
TitleFont.Name = 'Tahoma'<BR>&nbsp;&nbsp;&nbsp; TitleFont.Style = []<BR>&nbsp; 
end<BR>&nbsp; object Button1: TButton<BR>&nbsp;&nbsp;&nbsp; Left = 
8<BR>&nbsp;&nbsp;&nbsp; Top = 8<BR>&nbsp;&nbsp;&nbsp; Width = 
75<BR>&nbsp;&nbsp;&nbsp; Height = 25<BR>&nbsp;&nbsp;&nbsp; Caption = 
'Execute'<BR>&nbsp;&nbsp;&nbsp; TabOrder = 1<BR>&nbsp;&nbsp;&nbsp; OnClick = 
Button1Click<BR>&nbsp; end<BR>&nbsp; object Button2: 
TButton<BR>&nbsp;&nbsp;&nbsp; Left = 304<BR>&nbsp;&nbsp;&nbsp; Top = 
8<BR>&nbsp;&nbsp;&nbsp; Width = 75<BR>&nbsp;&nbsp;&nbsp; Height = 
25<BR>&nbsp;&nbsp;&nbsp; Caption = 'Close'<BR>&nbsp;&nbsp;&nbsp; TabOrder = 
2<BR>&nbsp;&nbsp;&nbsp; OnClick = Button2Click<BR>&nbsp; end<BR>&nbsp; object 
DataSource1: TDataSource<BR>&nbsp;&nbsp;&nbsp; DataSet = 
ClientDataSet1<BR>&nbsp;&nbsp;&nbsp; Left = 184<BR>&nbsp;&nbsp;&nbsp; Top = 
120<BR>&nbsp; end<BR>&nbsp; object ClientDataSet1: 
TClientDataSet<BR>&nbsp;&nbsp;&nbsp; Aggregates = &lt;&gt;<BR>&nbsp;&nbsp;&nbsp; 
Params = &lt;&gt;<BR>&nbsp;&nbsp;&nbsp; Left = 192<BR>&nbsp;&nbsp;&nbsp; Top = 
128<BR>&nbsp; end<BR>end</FONT></SPAN></DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=872553104-11022005><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</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>&nbsp;</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>&nbsp;</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?&nbsp; How does 
  one dynamically load rows into a DBGrid from 
  code?<o:p></o:p></SPAN></FONT></P></DIV></BLOCKQUOTE></BODY></HTML>