What you would need to do is build a datagrid manually one row at a time as
needed. When you construct a row, you will set the caption name and the
value items as you go along. This code creates 4 column datagrid. then adds
rows to it as needed
DataSet dsTemp = new DataSet();
DataTable Tables = new DataTable();
dsTemp.Tables.Add(Tables);
dsTemp.Tables[0].Columns.Add( " ", System.Type.GetType( "System.String" ) );
dsTemp.Tables[0].Columns.Add( "% variance", System.Type.GetType(
"System.Double" ) );
dsTemp.Tables[0].Columns.Add( "raw variance", System.Type.GetType(
"System.Double" ) );
dsTemp.Tables[0].Columns.Add( DateTime.Now.AddDays(-1).ToString("dddd
MM/dd/yyyy"), System.Type.GetType( "System.Double" ) );
dsTemp.Tables[0].Columns.Add( DateTime.Now.AddDays(-

.ToString("dddd
MM/dd/yyyy"), System.Type.GetType( "System.Double" ) );
for(int col = 0; col < ds.Tables[0].Columns.Count; col++)
{
DataRow myRow = dsTemp.Tables[0].NewRow();
myRow[4]= 0.00;
if(Double.TryParse(ds2.Tables[0].Rows[0][col].ToString(),
System.Globalization.NumberStyles.Any,
System.Globalization.NumberFormatInfo.InvariantInf o, out input))
myRow[4]= input.ToString();
myRow[3]= 0.00;
if(Double.TryParse(ds.Tables[0].Rows[0][col].ToString(),
System.Globalization.NumberStyles.Any,
System.Globalization.NumberFormatInfo.InvariantInf o, out input))
myRow[3]= input.ToString();
if(Double.TryParse((Double.Parse(myRow[3].ToString()) -
Double.Parse(myRow[4].ToString())).ToString(),
System.Globalization.NumberStyles.Any,
System.Globalization.NumberFormatInfo.InvariantInf o, out input))
myRow[2]= input.ToString();
if(ds2.Tables[0].Rows[0][col].ToString().Trim() != String.Empty)
myRow[1]= Math.Round(((Double.Parse(myRow[2].ToString()) /
Double.Parse(ds2.Tables[0].Rows[0][col].ToString())) * 100),2);
myRow[0]= ds.Tables[0].Columns[col].ColumnName;
dsTemp.Tables[0].Rows.Add(myRow);
}
Feel free to modify the code as you see fit.
--
Regards,
Alvin Bruney
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"Hai Nguyen" <> wrote in message
news:%...
> Hi all
>
> I'm trying to create form (can be anything, but a prefer it's a datagrid).
> It should look like this
>
> Header 1 Header 2 Header3 Header4 Header5
> (textbox) (textbox) (textbox) (textbox)
> (textbox)
> (textbox) (textbox) (textbox) (textbox)
> (textbox)
> (textbox) (textbox) (textbox) (textbox)
> (textbox)
> (textbox) (textbox) (textbox) (textbox)
> (textbox)
>
>
> My question is:
> 1/ Since I don't know the number of row in advance, if I'm still be able
to
> generate datagrid with a particular number of row (let's say 10 rows)
>
> 2/ Because the header is stored in a ArrayList, how do i bind those to the
> header
>
> 3/ After user fills out those textbox, I need to insert those infos to
> database, how can I do that?
>
> 4/ If users want to insert more than the rows printing, how can they add
> more rows?
>
> I appreciate any idea to get this problem solve.
>
> PS: If we can n't solve in datagrid, any solutions will be my big help
>
> Thanks everyone
>
>
>
>