private void addDataForm_Click(object sender, EventArgs e) { addDataForm f = new addDataForm(); f.ShowDialog(); }
//To display fields of selected row in edit box private void dataGridView2_CellClick(object sender, DataGridViewCellEventArgs e) { addDataForm f = new addDataForm(); // check if this is a header cell (e.rowIndex == -1). if yes then sort if (e.RowIndex == -1) { // we get the column the user has clicked DataGridViewColumn clickedColumn = this.dataGridView2.Columns[e.ColumnIndex]; this.dataGridView2.Sort(clickedColumn, ListSortDirection.Ascending); } else { string currentValueHere; currentValueHere = dataGridView2.Rows[e.RowIndex].Cells[1].Value.ToString(); f.identTextBox.Text = currentValueHere; currentValueHere = dataGridView2.Rows[e.RowIndex].Cells[3].Value.ToString(); f.nameTextBox.Text = currentValueHere; currentValueHere = dataGridView2.Rows[e.RowIndex].Cells[2].Value.ToString(); f.typeTextBox.Text = currentValueHere; currentValueHere = dataGridView2.Rows[e.RowIndex].Cells[4].Value.ToString(); //Seperation of Deg Min and Sec to display in addDataForm.(For Latitude) Regex r1 = new Regex("(°)"); String[] s = r1.Split(currentValueHere); string Deg = s[0]; string temp1 = s[2]; Regex r2 = new Regex("(')"); s = r2.Split(temp1); string Min = s[0]; temp1 = s[2]; Regex r3 = new Regex("(\")"); s = r3.Split(temp1); string Sec = s[0]; temp1 = s[2]; f.numericUpDownDegLat.Value = Convert.ToInt16(Deg); f.numericUpDownMinLat.Value = Convert.ToInt16(Min); f.numericUpDownSecLat.Value = Convert.ToInt16(Sec); f.NSTextBox.Text = temp1; currentValueHere = dataGridView2.Rows[e.RowIndex].Cells[5].Value.ToString(); f.addDataButton.Text = "Save"; //Seperation of Deg Min and Sec to display in addDataForm.(For Longitude) Regex r11 = new Regex("(°)"); String[] s1 = r11.Split(currentValueHere); string Deg1 = s1[0]; string temp11 = s1[2]; Regex r21 = new Regex("(')"); s1 = r21.Split(temp11); string Min1 = s1[0]; temp11 = s1[2]; Regex r31 = new Regex("(\")"); s1 = r31.Split(temp11); string Sec1 = s1[0]; temp11 = s1[2]; f.numericUpDownDegLong.Value = Convert.ToInt16(Deg1); f.numericUpDownMinLong.Value = Convert.ToInt16(Min1); f.numericUpDownSecLong.Value = Convert.ToInt16(Sec1); f.EWTextBox.Text = temp11; currentValueHere = dataGridView2.Rows[e.RowIndex].Cells[6].Value.ToString(); f.elevTextBox.Text = currentValueHere; currentValueHere = dataGridView2.Rows[e.RowIndex].Cells[8].Value.ToString(); f.freqTextBox.Text = currentValueHere; f.Show(); } }