473,386 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

parrentrow

hi all,

i'm just trying to get a datagrid like this and can't find it anywhere

+-parentrow(Analog Inputs)
childrow (DA1)
childrow (DA2)
childrow (DA3)
childrow (DA4)
+-parentrow(Analog Outputs)
childrow (AD1)
childrow (AD2)
childrow (AD3)
childrow (AD4)
childrow (AD5)
childrow (AD6)
childrow (AD7)
childrow (AD8)

with this datacourse

DataTable dtin = new DataTable("analogin");

dtin.Columns.Add("Read",Type.GetType("System.Strin g"));

dtin.Columns.Add("Channel",Type.GetType("System.St ring"));

dtin.Columns.Add("Value",Type.GetType("System.Stri ng"));
dtin.Rows.Add(dtin.NewRow());

dtin.Rows[0][0]=true;

dtin.Rows[0][1]="DAC1";

dtin.Rows[0][2]= analogvalin[0];

dtin.Rows.Add(dtin.NewRow());

dtin.Rows[1][0]=false;

dtin.Rows[1][1]="DAC2";

dtin.Rows[1][2]=analogvalin[1];

dataGrid2.DataSource = dtin;

dtin.Rows.Add(dtin.NewRow());

dtin.Rows[2][0]=true;

dtin.Rows[2][1]="DAC3";

dtin.Rows[2][2]= analogvalin[2];

dtin.Rows.Add(dtin.NewRow());

dtin.Rows[3][0]=false;

dtin.Rows[3][1]="DAC4";

dtin.Rows[3][2]=analogvalin[3];;

}

DataTable dtout = new DataTable("analogout");

dtout.Columns.Add("Read",Type.GetType("System.Stri ng"));

dtout.Columns.Add("Channel",Type.GetType("System.S tring"));

dtout.Columns.Add("Value",Type.GetType("System.Str ing"));

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[0][0]=true;

dtout.Rows[0][1]="DAC1";

dtout.Rows[0][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[1][0]=false;

dtout.Rows[1][1]="DAC2";

dtout.Rows[1][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[2][0]=true;

dtout.Rows[2][1]="DAC3";

dtout.Rows[2][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[3][0]=false;

dtout.Rows[3][1]="DAC4";

dtout.Rows[3][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[4][0]=true;

dtout.Rows[4][1]="DAC5";

dtout.Rows[4][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[5][0]=true;

dtout.Rows[5][1]="DAC6";

dtout.Rows[5][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[6][0]=true;

dtout.Rows[6][1]="DAC7";

dtout.Rows[6][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[7][0]=true;

dtout.Rows[7][1]="DAC8";

dtout.Rows[7][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[8][0]=true;

dtout.Rows[8][1]="DA9";

dtout.Rows[8][2]="0";

dataGrid1.DataSource = dtout;

}

I don't think this can be verry hard

Greets Maarten
Nov 16 '05 #1
3 1182
Maarten,

After you create the structure for the tables in your dataset, you need
to add an instance of the DataRelation class, which indicates how the child
and the parent row are linked.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Maarten" <gu******@hotmail.com> wrote in message
news:42***********************@news.skynet.be...
hi all,

i'm just trying to get a datagrid like this and can't find it anywhere

+-parentrow(Analog Inputs)
childrow (DA1)
childrow (DA2)
childrow (DA3)
childrow (DA4)
+-parentrow(Analog Outputs)
childrow (AD1)
childrow (AD2)
childrow (AD3)
childrow (AD4)
childrow (AD5)
childrow (AD6)
childrow (AD7)
childrow (AD8)

with this datacourse

DataTable dtin = new DataTable("analogin");

dtin.Columns.Add("Read",Type.GetType("System.Strin g"));

dtin.Columns.Add("Channel",Type.GetType("System.St ring"));

dtin.Columns.Add("Value",Type.GetType("System.Stri ng"));
dtin.Rows.Add(dtin.NewRow());

dtin.Rows[0][0]=true;

dtin.Rows[0][1]="DAC1";

dtin.Rows[0][2]= analogvalin[0];

dtin.Rows.Add(dtin.NewRow());

dtin.Rows[1][0]=false;

dtin.Rows[1][1]="DAC2";

dtin.Rows[1][2]=analogvalin[1];

dataGrid2.DataSource = dtin;

dtin.Rows.Add(dtin.NewRow());

dtin.Rows[2][0]=true;

dtin.Rows[2][1]="DAC3";

dtin.Rows[2][2]= analogvalin[2];

dtin.Rows.Add(dtin.NewRow());

dtin.Rows[3][0]=false;

dtin.Rows[3][1]="DAC4";

dtin.Rows[3][2]=analogvalin[3];;

}

DataTable dtout = new DataTable("analogout");

dtout.Columns.Add("Read",Type.GetType("System.Stri ng"));

dtout.Columns.Add("Channel",Type.GetType("System.S tring"));

dtout.Columns.Add("Value",Type.GetType("System.Str ing"));

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[0][0]=true;

dtout.Rows[0][1]="DAC1";

dtout.Rows[0][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[1][0]=false;

dtout.Rows[1][1]="DAC2";

dtout.Rows[1][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[2][0]=true;

dtout.Rows[2][1]="DAC3";

dtout.Rows[2][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[3][0]=false;

dtout.Rows[3][1]="DAC4";

dtout.Rows[3][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[4][0]=true;

dtout.Rows[4][1]="DAC5";

dtout.Rows[4][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[5][0]=true;

dtout.Rows[5][1]="DAC6";

dtout.Rows[5][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[6][0]=true;

dtout.Rows[6][1]="DAC7";

dtout.Rows[6][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[7][0]=true;

dtout.Rows[7][1]="DAC8";

dtout.Rows[7][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[8][0]=true;

dtout.Rows[8][1]="DA9";

dtout.Rows[8][2]="0";

dataGrid1.DataSource = dtout;

}

I don't think this can be verry hard

Greets Maarten

Nov 16 '05 #2
Hi Nicholas

this is what i did
but ist won't work it says :

Object reference not set to an instance of an object.

Thanks in advance
DataTable dtout = new DataTable("analogout");

dtout.Columns.Add("Read",Type.GetType("System.Stri ng"));

dtout.Columns.Add("Channel",Type.GetType("System.S tring"));

dtout.Columns.Add("Value",Type.GetType("System.Str ing"));

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[0][0]=true;

dtout.Rows[0][1]="DAC1";

dtout.Rows[0][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[1][0]=false;

dtout.Rows[1][1]="DAC2";

dtout.Rows[1][2]="0";
DataTable dtin = new DataTable("analogin");

dtin.Columns.Add("Read",Type.GetType("System.Strin g"));

dtin.Columns.Add("Channel",Type.GetType("System.St ring"));

dtin.Columns.Add("Value",Type.GetType("System.Stri ng"));

dtin.Rows.Add(dtin.NewRow());

dtin.Rows[0][0]=true;

dtin.Rows[0][1]="DAC1";

dtin.Rows[0][2]= analogvalin[0];

dtin.Rows.Add(dtin.NewRow());

dtin.Rows[1][0]=false;

dtin.Rows[1][1]="DAC2";

dtin.Rows[1][2]=analogvalin[1];

DataTable dt = new DataTable("parent");

dt.Columns.Add("name",Type.GetType("System.String" ));
System.Data.DataColumn parentCol;

System.Data.DataColumn childCol;

parentCol = ds.Tables["parent"].Columns["name"];

childCol = ds.Tables["analogout"].Columns["Read"];

// create a Relation called "analog"

DataRelation dr = new DataRelation("analog", parentCol, childCol);

// add a relation

ds.Relations.Add(dr);

dataGrid3.DataSource = dr;

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> schreef
in bericht news:es**************@TK2MSFTNGP09.phx.gbl...
Maarten,

After you create the structure for the tables in your dataset, you need
to add an instance of the DataRelation class, which indicates how the
child and the parent row are linked.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Maarten" <gu******@hotmail.com> wrote in message
news:42***********************@news.skynet.be...
hi all,

i'm just trying to get a datagrid like this and can't find it anywhere

+-parentrow(Analog Inputs)
childrow (DA1)
childrow (DA2)
childrow (DA3)
childrow (DA4)
+-parentrow(Analog Outputs)
childrow (AD1)
childrow (AD2)
childrow (AD3)
childrow (AD4)
childrow (AD5)
childrow (AD6)
childrow (AD7)
childrow (AD8)

with this datacourse

DataTable dtin = new DataTable("analogin");

dtin.Columns.Add("Read",Type.GetType("System.Strin g"));

dtin.Columns.Add("Channel",Type.GetType("System.St ring"));

dtin.Columns.Add("Value",Type.GetType("System.Stri ng"));
dtin.Rows.Add(dtin.NewRow());

dtin.Rows[0][0]=true;

dtin.Rows[0][1]="DAC1";

dtin.Rows[0][2]= analogvalin[0];

dtin.Rows.Add(dtin.NewRow());

dtin.Rows[1][0]=false;

dtin.Rows[1][1]="DAC2";

dtin.Rows[1][2]=analogvalin[1];

dataGrid2.DataSource = dtin;

dtin.Rows.Add(dtin.NewRow());

dtin.Rows[2][0]=true;

dtin.Rows[2][1]="DAC3";

dtin.Rows[2][2]= analogvalin[2];

dtin.Rows.Add(dtin.NewRow());

dtin.Rows[3][0]=false;

dtin.Rows[3][1]="DAC4";

dtin.Rows[3][2]=analogvalin[3];;

}

DataTable dtout = new DataTable("analogout");

dtout.Columns.Add("Read",Type.GetType("System.Stri ng"));

dtout.Columns.Add("Channel",Type.GetType("System.S tring"));

dtout.Columns.Add("Value",Type.GetType("System.Str ing"));

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[0][0]=true;

dtout.Rows[0][1]="DAC1";

dtout.Rows[0][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[1][0]=false;

dtout.Rows[1][1]="DAC2";

dtout.Rows[1][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[2][0]=true;

dtout.Rows[2][1]="DAC3";

dtout.Rows[2][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[3][0]=false;

dtout.Rows[3][1]="DAC4";

dtout.Rows[3][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[4][0]=true;

dtout.Rows[4][1]="DAC5";

dtout.Rows[4][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[5][0]=true;

dtout.Rows[5][1]="DAC6";

dtout.Rows[5][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[6][0]=true;

dtout.Rows[6][1]="DAC7";

dtout.Rows[6][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[7][0]=true;

dtout.Rows[7][1]="DAC8";

dtout.Rows[7][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[8][0]=true;

dtout.Rows[8][1]="DA9";

dtout.Rows[8][2]="0";

dataGrid1.DataSource = dtout;

}

I don't think this can be verry hard

Greets Maarten


Nov 16 '05 #3
Hi,

i fugured out how to set the datarelation, this works fine.

but now my problems is , that the dararelation is just a link to another
table in the same grid.
is it possible that the table is extracted below the parrentrow?

thanks Maarten
"Maarten" <gu******@hotmail.com> schreef in bericht
news:42***********************@news.skynet.be...
Hi Nicholas

this is what i did
but ist won't work it says :

Object reference not set to an instance of an object.

Thanks in advance
DataTable dtout = new DataTable("analogout");

dtout.Columns.Add("Read",Type.GetType("System.Stri ng"));

dtout.Columns.Add("Channel",Type.GetType("System.S tring"));

dtout.Columns.Add("Value",Type.GetType("System.Str ing"));

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[0][0]=true;

dtout.Rows[0][1]="DAC1";

dtout.Rows[0][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[1][0]=false;

dtout.Rows[1][1]="DAC2";

dtout.Rows[1][2]="0";
DataTable dtin = new DataTable("analogin");

dtin.Columns.Add("Read",Type.GetType("System.Strin g"));

dtin.Columns.Add("Channel",Type.GetType("System.St ring"));

dtin.Columns.Add("Value",Type.GetType("System.Stri ng"));

dtin.Rows.Add(dtin.NewRow());

dtin.Rows[0][0]=true;

dtin.Rows[0][1]="DAC1";

dtin.Rows[0][2]= analogvalin[0];

dtin.Rows.Add(dtin.NewRow());

dtin.Rows[1][0]=false;

dtin.Rows[1][1]="DAC2";

dtin.Rows[1][2]=analogvalin[1];

DataTable dt = new DataTable("parent");

dt.Columns.Add("name",Type.GetType("System.String" ));
System.Data.DataColumn parentCol;

System.Data.DataColumn childCol;

parentCol = ds.Tables["parent"].Columns["name"];

childCol = ds.Tables["analogout"].Columns["Read"];

// create a Relation called "analog"

DataRelation dr = new DataRelation("analog", parentCol, childCol);

// add a relation

ds.Relations.Add(dr);

dataGrid3.DataSource = dr;

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> schreef
in bericht news:es**************@TK2MSFTNGP09.phx.gbl...
Maarten,

After you create the structure for the tables in your dataset, you
need to add an instance of the DataRelation class, which indicates how
the child and the parent row are linked.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Maarten" <gu******@hotmail.com> wrote in message
news:42***********************@news.skynet.be...
hi all,

i'm just trying to get a datagrid like this and can't find it anywhere

+-parentrow(Analog Inputs)
childrow (DA1)
childrow (DA2)
childrow (DA3)
childrow (DA4)
+-parentrow(Analog Outputs)
childrow (AD1)
childrow (AD2)
childrow (AD3)
childrow (AD4)
childrow (AD5)
childrow (AD6)
childrow (AD7)
childrow (AD8)

with this datacourse

DataTable dtin = new DataTable("analogin");

dtin.Columns.Add("Read",Type.GetType("System.Strin g"));

dtin.Columns.Add("Channel",Type.GetType("System.St ring"));

dtin.Columns.Add("Value",Type.GetType("System.Stri ng"));
dtin.Rows.Add(dtin.NewRow());

dtin.Rows[0][0]=true;

dtin.Rows[0][1]="DAC1";

dtin.Rows[0][2]= analogvalin[0];

dtin.Rows.Add(dtin.NewRow());

dtin.Rows[1][0]=false;

dtin.Rows[1][1]="DAC2";

dtin.Rows[1][2]=analogvalin[1];

dataGrid2.DataSource = dtin;

dtin.Rows.Add(dtin.NewRow());

dtin.Rows[2][0]=true;

dtin.Rows[2][1]="DAC3";

dtin.Rows[2][2]= analogvalin[2];

dtin.Rows.Add(dtin.NewRow());

dtin.Rows[3][0]=false;

dtin.Rows[3][1]="DAC4";

dtin.Rows[3][2]=analogvalin[3];;

}

DataTable dtout = new DataTable("analogout");

dtout.Columns.Add("Read",Type.GetType("System.Stri ng"));

dtout.Columns.Add("Channel",Type.GetType("System.S tring"));

dtout.Columns.Add("Value",Type.GetType("System.Str ing"));

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[0][0]=true;

dtout.Rows[0][1]="DAC1";

dtout.Rows[0][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[1][0]=false;

dtout.Rows[1][1]="DAC2";

dtout.Rows[1][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[2][0]=true;

dtout.Rows[2][1]="DAC3";

dtout.Rows[2][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[3][0]=false;

dtout.Rows[3][1]="DAC4";

dtout.Rows[3][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[4][0]=true;

dtout.Rows[4][1]="DAC5";

dtout.Rows[4][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[5][0]=true;

dtout.Rows[5][1]="DAC6";

dtout.Rows[5][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[6][0]=true;

dtout.Rows[6][1]="DAC7";

dtout.Rows[6][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[7][0]=true;

dtout.Rows[7][1]="DAC8";

dtout.Rows[7][2]="0";

dtout.Rows.Add(dtout.NewRow());

dtout.Rows[8][0]=true;

dtout.Rows[8][1]="DA9";

dtout.Rows[8][2]="0";

dataGrid1.DataSource = dtout;

}

I don't think this can be verry hard

Greets Maarten



Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.