dt = new DataTable(); dc = new DataColumn(); dc.ColumnName = "Time"; // x-axis title; dt.Columns.Add(dc); dc = new DataColumn(); dc.ColumnName = "Score"; // y-axis title dt.Columns.Add(dc); for (int i = 0; i < 750; i++) { Random r = new Random(); DataRow dr;//add rows dr = dt.NewRow(); dr["Time"] = index; dr["Score"] = r.Next(10, 99); dt.Rows.Add(dr); if (index >= 30) { DataRow rowRemoved = dt.Rows[0]; dt.Rows.Remove(rowRemoved); } dataGridView1.DataSource = dt; chart1.DataSource = dt; chart1.Series["Series1"].XValueMember = "Time"; chart1.Series["Series1"].YValueMembers = "Score"; chart1.DataBind(); index++; Application.DoEvents(); }
chart1.DataBind()
Application.DoEvents()
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)