As a follow up, I played around with it and again, depending on what you
meant..
object[] o = new object[lb1.Items.Count];
lb1.Items.CopyTo(o,0);
DataTable dt = new DataTable("CuckooTable");
DataColumn dc = new DataColumn("CuckooColumn");
DataColumn dc2 = new DataColumn("CuckooColumn2");
dt.Columns.Add(dc);
dt.Columns.Add(dc2);
dt.Rows.Add(o);
However, this is another approach you can use if you have multiple columns.
Tell me a little more about what you need and I'll see what I can do:
private void GrabControls(Control ctrl)
{
foreach(Control ctrl in this.Controls)
{
if(ctrl.HasChildren)
{
GrabControls(ctrl);
}
else
{
if(typeof(ctrl) is ListBox)
{
object[] o = new object[(ctrl as ListBox).Items.Count];
lb1.Items.CopyTo(o,0);
DataTable dt = new DataTable("CuckooTable");//This needs to change each time
//If you want to add it to a dataset. Plus, you can just create a table
//and not have to add the columns at each pass, but if you're
//using a typed dataset than you don't need to do this at all.
DataColumn dc = new DataColumn("CuckooColumn");
DataColumn dc2 = new DataColumn("CuckooColumn2");
dt.Columns.Add(dc);
dt.Columns.Add(dc2);
dt.Rows.Add(o);
}
}
}
}