private void showTable_certainData_Click(object sender, RoutedEventArgs e) { timer.Stop(); if (datalist == null) { MessageBox.Show("没有数据"); return; } DataTable tbl = new DataTable(); tbl.Columns.Add("time"); tbl.Columns.Add("light Intesity"); for (int m = 0; m < datalist.Count; m++) { tbl.Rows.Add((m * collectDataTime).ToString() + "s", ((DataUnit)datalist[m]).da[(int)waveIndex]); } ShowTable showTbl = new ShowTable(tbl); showTbl.Show(); }
private void showTable_allData_Click(object sender, RoutedEventArgs e) { timer.Stop(); if (datalist == null) { MessageBox.Show("没有数据"); return; } // int wl; DataTable dtbl = new DataTable(); dtbl.Columns.Add("time"); for (int i = 0; i < 2068; i++) { dtbl.Columns.Add(i.ToString(), typeof(double)); //将i换为String.Format( "{0:F} ",wavelengthArray[i])却不行。。。 } for (int j = 0; j < datalist.Count; j++) { DataRow cRow = dtbl.NewRow(); object[] rowData = new object[2069]; rowData[0] = j; for (int m = 0; m < 2068; m++) { rowData[m + 1] = ((DataUnit)datalist[j]).da[m]; } cRow.ItemArray = rowData; dtbl.Rows.Add(cRow); } ShowTable showTbl = new ShowTable(dtbl); showTbl.Show(); }