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.
Thank you for your time
Regards
Anthony
Loading

Sam HobbsRank #107 · 20.5K reputationPosted Dec 11, 2010, 6:22 PM EST
http://social.msdn.microsoft.com/Search/en-US?query=random&ac=8
There you will find the Random Class. Does that help?
Subhendu DeRank #1,108 · 1.7K reputationPosted Dec 11, 2010, 2:40 AM EST
Thanks.....
Anthony Clarke99 reputationPosted Dec 11, 2010, 2:51 AM EST
Thanks for your response.
I know how to bind the datasource to the datagridview but how to i randomize the datasource. I just want to populate a grid e.g.
Columns A B C D E with 100 rows which are all random numbers.
Im just not sure how to tackle this.
Thanks Subhendu
Regards
Anthony
Suthish NairRank #92 · 22.8K reputationPosted Dec 11, 2010, 10:23 AM EST
random rows sql server
Anthony Clarke99 reputationPosted Dec 12, 2010, 6:05 AM EST
Anthony
CrishRank #1,486 · 1.1K reputationPosted Dec 12, 2010, 11:56 PM EST
You can refer following code.
private void pictureBox1_Click(object sender, EventArgs e)
{
string query=null;
query = "select * from Studies";
SqlCeDataAdapter adp = new SqlCeDataAdapter(query, "Data Source=Dicom.sdf;Persist Security Info=False;");
DataTable dt = new DataTable();
dt.Locale = System.Globalization.CultureInfo.InvariantCulture;
adp.Fill(dt);
StudiesbindingSource.DataSource = dt;
dataGridViewStudies.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);// Resize the DataGridView columns to fit the newly loaded content.
dataGridViewStudies.ReadOnly = true; // finally bind the data to the grid
dataGridViewStudies.DataSource = StudiesbindingSource;
dataGridViewStudies.Visible = true;
}