private void button1_Click(object sender, EventArgs e) { bool error = false; Logic.Instance.Frequencies.Clear(); for (int i = 0; i < dataGridView1.Rows.Count; i++) { object obj = dataGridView1[0, i].Value; if (obj != null) { string val = obj.ToString(); //double variable = Convert.ToDouble(val); if (val != "0" && val != null) //Convert.ToDouble(.ToString().Replace(".",",")) { try { double numb = Convert.ToDouble(val); // dataGridView1[0, i].Value.ToString().Replace(".", ",") Logic.Instance.Frequencies.Add(Convert.ToDouble(val) * 1e9); //dataGridView1[0, i].Value.ToString().Replace(",", ".") dataGridView1[0, i].Style.ForeColor = System.Drawing.SystemColors.WindowText; error = false; } catch (Exception) { dataGridView1[0, i].Style.ForeColor = Color.FromArgb(220, 40, 20); dataGridView1.ClearSelection(); error = true; } } } } if (!error) { parent.AddFrequenciesToTreeView(Logic.Instance.Frequencies); Close(); } }