private void button_Click(object sender, EventArgs e) { Button btn = sender as Button; LoadData ld = new LoadData(); //dgv.Rows.Add("AAAAAAAAAAAAAAA\n\rAAAAAAAAAAAAAAA\n\rAAAAAAAAAAAAAAA\n\rAAAAAAAAAAAAAAA\n\r"); //dgv.Rows[0].Height = 100; ld.TypeNo = "TYPE " + txt_type.Text; //ld.TypeNo = "TYPE " + (dgv.RowCount + 1); ld.Code = txt_lm.Text; ld.Distances = new MyList(txt_distances.Text.Replace(",", " "), ' '); ld.Loads = new MyList(txt_loads.Text.Replace(",", " "), ' '); ld.LoadWidth = MyList.StringToDouble(txt_load_width.Text, 0.0); ld.ImpactFactor = MyList.StringToDouble(txt_imf.Text, 1.0); if (btn.Name == btn_save.Name) { try { Loads.Save_LL_TXT(System.IO.Path.GetDirectoryName(Live_Load_File), true); //Loads.Save_LL_TXT(System.IO.Path.GetDirectoryName(iapp.LL_TXT_Path), true); //Loads.Save_LL_TXT(Application.StartupPath, true); DialogResult = DialogResult.OK; this.Close(); } catch (Exception ex) { } } else if (btn.Name == btn_cancel.Name) { DialogResult = DialogResult.Cancel; this.Close(); } else if (btn.Name == btn_restore.Name) { try { if (MessageBox.Show("Do you want to restore default Moving Load Data ?", "ASTRA", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { iapp.Write_Default_LiveLoad_Data(); Read_Loads(); } } catch (Exception ex) { } } else if (ld.Distances.Count != (ld.Loads.Count - 1)) { string s = string.Format("Number of Distances = {0} and Number of Loads = {1}", ld.Distances.Count, ld.Loads.Count); MessageBox.Show(this, s + "\n\nNumber of Distances must be equal to " + (ld.Loads.Count - 1) + " (Number of Loads - 1).", "ASTRA", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (btn.Name == btn_new.Name) { txt_type.Text = (dgv.RowCount + 1).ToString(); ld.TypeNo = "TYPE " + txt_type.Text; Loads.Add(ld); dgv.Rows.Add(ld.Data); } else if (btn.Name == btn_update.Name) { try { Loads[dgv.CurrentCell.RowIndex] = ld; dgv[0, dgv.CurrentCell.RowIndex].Value = ld.Data; Select_Loads(dgv.CurrentCell.RowIndex); } catch (Exception ex) { } } else if (btn.Name == btn_delete.Name) { try { Loads.RemoveAt(dgv.CurrentCell.RowIndex); dgv.Rows.RemoveAt(dgv.CurrentCell.RowIndex); //dgv.Rows[0].Selected = true; } catch (Exception ex) { } } }