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 HobbsPosted Dec 11, 2010, 11:22 PM
http://social.msdn.microsoft.com/Search/en-US?query=random&ac=8
There you will find the Random Class. Does that help?
CrishPosted Dec 13, 2010, 4:56 AM
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;
}
Anthony ClarkePosted Dec 12, 2010, 11:05 AM
Anthony
Suthish NairPosted Dec 11, 2010, 3:23 PM
random rows sql server
Anthony ClarkePosted Dec 11, 2010, 7:51 AM
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
Subhendu DePosted Dec 11, 2010, 7:40 AM
Thanks.....