WFA_psychometric_chart.Form1_main.clearChartToolStripMenuItem_Click C# (CSharp) Method

clearChartToolStripMenuItem_Click() private method

private clearChartToolStripMenuItem_Click ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        private void clearChartToolStripMenuItem_Click(object sender, EventArgs e)
        {


            try { 

            if (MessageBox.Show("Are you sure you want to clear this chart?", "Clear chart", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
            //if (dialogResult == DialogResult.Yes)
            {

                //--This function should clear the chart 
                /*
                Steps :
                0.Find which chart is selected.
                1. delete the information from the chart of both node and line
                2. Re plot the chart function 
                */

                string chartidsel = chartDetailList[indexOfChartSelected].chartID;
                string chart_resp_nodeIDX = chartDetailList[indexOfChartSelected].chart_respective_nodeID;
                string chart_resp_lineIDX = chartDetailList[indexOfChartSelected].chart_respective_lineID;

                //Deleting the content of the chart 
                DeleteChartContent(chartidsel, chart_resp_nodeIDX, chart_resp_lineIDX);//This deletes the content of chart

                ClearChart();
                /*
                clear chart will erase the the menustrip info of line and node so replotting it again
                */
                dataGridView1.Rows.Clear();
                DataGridView_Show_Data();
                dataGridView1.Rows.Add();

                //Select the chart with was selected
                if (chartDetailList.Count > indexOfChartSelected)
                {
                    //We need to select the particular index 
                    //--I hope this will do the replotting thing as well
                    dataGridView1.Rows[indexOfChartSelected].Selected = true;//The row is selected 

                }

                //if (dataGridView1.CurrentCell.RowIndex.ToString() != "")
                //{
                //    //set parameters of your event args
                //    var eventArgs = new DataGridViewCellEventArgs(1, dataGridView1.CurrentCell.RowIndex);
                //    //or setting the selected cells manually before executing the function
                //    //dataGridView2.Rows[dataGridView2.CurrentCell.RowIndex].Cells[dataGridView2.CurrentCell.ColumnIndex].Selected = true;
                //    dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[1].Selected = true;
                //    dataGridView1_CellClick(sender, eventArgs);
                //}





            }//Close of clear chart

            }catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Form1_main