dataGridView1.SelectAll(); numCells = dataGridView1.SelectedCells.Count; for (i = 14; i < (numCells); i += 14) { if (i < numCells) { if (Convert.ToDouble(dataGridView1.SelectedCells[i + 11].Value.ToString()) == 28.464258839) { UCS1size += 1; } else if (Convert.ToDouble(dataGridView1.SelectedCells[i + 11].Value.ToString()) == 28.42859146) { MOCsize += 1; } else if (Convert.ToDouble(dataGridView1.SelectedCells[i + 11].Value.ToString()) == 28.490616471) { AMsize += 1; } else if (Convert.ToDouble(dataGridView1.SelectedCells[i + 11].Value.ToString()) == 28.525409911) { UCS2size += 1; } else if (Convert.ToDouble(dataGridView1.SelectedCells[i + 11].Value.ToString()) == 28.560529988) { LC40size += 1; } } else { MessageBox.Show("exiting for loop. numcells: " + numCells); } } double[] freqLC40 = new double[LC40size]; double[] ampMaxLC40 = new double[LC40size]; double[] freqMOC = new double[MOCsize]; double[] ampMaxMOC = new double[MOCsize]; double[] freqUCS1 = new double[UCS1size]; double[] ampMaxUCS1 = new double[UCS1size]; double[] freqUCS2 = new double[UCS2size]; double[] ampMaxUCS2 = new double[UCS2size]; double[] freqAM = new double[AMsize]; double[] ampMaxAM = new double[AMsize]; int LC40idx = 0; int MOCidx = 0; int UCS1idx = 0; int UCS2idx = 0; int AMsidx = 0; for (i = 14; i < (numCells); i += 14) { if (i < numCells) { if (Convert.ToDouble(dataGridView1.SelectedCells[i + 11].Value.ToString()) == 28.464258839) { freqUCS1[UCS1idx] = Convert.ToDouble(dataGridView1.SelectedCells[i].Value.ToString()); ampMaxUCS1[UCS1idx] = Convert.ToDouble(dataGridView1.SelectedCells[i + 9].Value.ToString()); UCS1idx += 1; } else if (Convert.ToDouble(dataGridView1.SelectedCells[i + 11].Value.ToString()) == 28.42859146) { freqMOC[MOCidx] = Convert.ToDouble(dataGridView1.SelectedCells[i].Value.ToString()); ampMaxMOC[MOCidx] = Convert.ToDouble(dataGridView1.SelectedCells[i + 9].Value.ToString()); MOCidx += 1; } else if (Convert.ToDouble(dataGridView1.SelectedCells[i + 11].Value.ToString()) == 28.490616471) { freqAM[AMsidx] = Convert.ToDouble(dataGridView1.SelectedCells[i].Value.ToString()); ampMaxAM[AMsidx] = Convert.ToDouble(dataGridView1.SelectedCells[i + 9].Value.ToString()); AMsidx += 1; } else if (Convert.ToDouble(dataGridView1.SelectedCells[i + 11].Value.ToString()) == 28.525409911) { freqUCS2[UCS2idx] = Convert.ToDouble(dataGridView1.SelectedCells[i].Value.ToString()); ampMaxUCS2[UCS2idx] = Convert.ToDouble(dataGridView1.SelectedCells[i + 9].Value.ToString()); UCS2idx += 1; } else if (Convert.ToDouble(dataGridView1.SelectedCells[i + 11].Value.ToString()) == 28.560529988) { freqLC40[LC40idx] = Convert.ToDouble(dataGridView1.SelectedCells[i].Value.ToString()); ampMaxLC40[LC40idx] = Convert.ToDouble(dataGridView1.SelectedCells[i + 9].Value.ToString()); LC40idx += 1; } } else { MessageBox.Show("exiting for loop. numcells: " + numCells); } } //get XY form LC40 xyForm = new XYplotForm(); xyForm.Plot(freqLC40, ampMaxLC40, "LC-40 Max Amplitude"); xyForm.Show();
using System.Linq; ... double[] array = new double[10]; List<double> list = array.ToList();
double[] array = new double[10]; List<double> list = new List<double>(array);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)