Hi,
I want to populate a datagrid view with quite a bit of random data but dont want to have to keep using
datagridview.columns.add("etc")
datagridview.rows.add("etc")
a few hundread times and was wondering whether there is a quick method for this.
Something like
for (int i = 0; i < int 100; i++;
{
datagrid.columns.add("1", "2", "3", "4")
datagrid.rows[i].add(rnd 10000)
}
Thank you for your time
Regards
Anthony
Loading
Subhendu DePosted Dec 11, 2010, 2:21 PM
dataGridView1.ColumnCount = 4;
dataGridView1.Columns[0].Name = "Column1";
dataGridView1.Columns[1].Name = "Column2";
dataGridView1.Columns[2].Name = "Column3";
dataGridView1.Columns[3].Name = "Column4";
for (int i = 0; i < 100; i++)
{
// Replace this array with a Random number generation
string[] _num = new string[] { "AAA", "BBB", "CCC", "DDD" };
dataGridView1.Rows.Add(_num);
}
Thanks.....
CrishPosted Dec 14, 2010, 5:58 AM
I have same problem.Thanks for code it will help us to solve our issue of datagridview.
Sam HobbsPosted Dec 11, 2010, 11:59 PM
Anthony ClarkePosted Dec 11, 2010, 4:15 PM
Thanks Subhendu :-)
Regards
Anthony
Suthish NairPosted Dec 11, 2010, 3:33 PM
Why you creating duplicate posts?