Hi,
Can you tell me how to make the numbers more random, it uses the same numbers in so many fields, i need them to be as different as possible essentially.
If you run this code you will see what i mean.
dataGridView2.ColumnCount = 4;
dataGridView2.Columns[0].Name = "Column1";
dataGridView2.Columns[1].Name = "Column2";
dataGridView2.Columns[2].Name = "Column3";
dataGridView2.Columns[3].Name = "Column4";
for (int i = 0; i < 100; i++)
{
Random t = new Random();
int get = t.Next(1, 1000);
int set = t.Next(1, 1000);
int ready = t.Next(1, 1000);
int go = t.Next(1, 1000);
dataGridView2.Rows.Add(get, set, ready, go);
Thanks
Anthony
Loading
Sam HobbsPosted Dec 12, 2010, 1:10 PM
Anthony ClarkePosted Dec 13, 2010, 5:41 AM
Thanks to both of you :-)
Subhendu DePosted Dec 13, 2010, 4:44 AM
Anthony,
This is the code. Try it out and request you to accept his post as answer.
dataGridView1.ColumnCount = 4;
dataGridView1.Columns[0].Name = "Column1";
dataGridView1.Columns[1].Name = "Column2";
dataGridView1.Columns[2].Name = "Column3";
dataGridView1.Columns[3].Name = "Column4";
Random t = new Random();
for (int i = 0; i < 100; i++)
{
int get = t.Next(1, 1000);
int set = t.Next(1, 1000);
int ready = t.Next(1, 1000);
int go = t.Next(1, 1000);
dataGridView1.Rows.Add(get, set, ready, go);
}
Thanks.....
Mahesh ChandPosted Dec 12, 2010, 11:23 AM
Please do not post same questions on multiple forum categories.
Thanks!
Anthony ClarkePosted Dec 12, 2010, 11:09 AM
No its not the same, its pretty much the same code but i couldnt even populate random before, but now it just doesnt seem that random there are chunks of 20 all with the same data so im trying to find a method that ill give me almost unique values and not 20 of this number 20 of another etc.
Thanks
Anthony
Subhendu DePosted Dec 12, 2010, 12:34 AM
http://www.c-sharpcorner.com/UploadFile/rmcochran/random07172006175425PM/random.aspx
Thanks.....
Sam HobbsPosted Dec 12, 2010, 12:02 AM