public Form1() { InitializeComponent(); // I think this should be in form load. I need it to run one time to set up the bouncegraph data table. Form Load didn't want to run for me?? DataColumn dc; BG_Detail.b_Initialized = true; dc = new DataColumn(); dc.ColumnName = "DropDate"; Form_BounceGraph_DT.Columns.Add(dc); dc = new DataColumn(); dc.ColumnName = "GraphDays"; Form_BounceGraph_DT.Columns.Add(dc); dc = new DataColumn(); dc.ColumnName = "RecoverDays"; Form_BounceGraph_DT.Columns.Add(dc); dc = new DataColumn(); dc.ColumnName = "Price"; Form_BounceGraph_DT.Columns.Add(dc); dc = new DataColumn(); dc.ColumnName = "DropPct"; Form_BounceGraph_DT.Columns.Add(dc); dc = new DataColumn(); dc.ColumnName = "TickerID"; Form_BounceGraph_DT.Columns.Add(dc); BounceGraph.DataSource = Form_BounceGraph_DT; BounceGraph.Series[0].XValueMember = "DropDate"; BounceGraph.Series[0].YValueMembers = "GraphDays"; BounceGraph.DataBind(); }
/* *************************************************************************************************************************************************************** * This is the best routine I found to identify when a user picks a symbol from the list of symbols. * It will display the stock activity for that ticker in the line chart on the bottom right of the form * and the times that stock dropped below the percent entered in a single day with the days it took to recover as * the bar chart amount. * *************************************************************************************************************************************************************** */ private void dataGridVBounce_CellRowEnter(object sender, DataGridViewCellEventArgs e) { // Interesting thing happens here. The first selection you make after a grid reset doesn't catch here? // It acts like you have to double click the first row to take an action? string dgr_symbol = "xxx"; bool DummyFlag = false; int bri = e.RowIndex; double gvb_TodaysPrice = 0.0; int gvb_Tickerid = 0; string gvb_Date; int gvb_counter = 0; StockAnalysis gvb_Look = new StockAnalysis(); gvb_Look.ClearBounces(); DummyFlag = Check_on_pct(gvb_Look); if (!Form_BounceinProgress) { // OK so I'm changing things up here a bit. Instead of adding XY elements to bouncegraph I'm going to fill a datatable bound to the graph in the stock analyis routines. // This section will be respobsible for clearing the table and setting the global row value. //BounceinProgress = true; dgr_symbol = dataGridVBounce.Rows[bri].Cells[0].Value.ToString(); DataRow dr; // Initialize the query BounceBack.BounceData2DataSetTableAdapters.DailyQuoteTableAdapter BBDGQ; BBDGQ = new BounceData2DataSetTableAdapters.DailyQuoteTableAdapter(); BounceData2DataSet.DailyQuoteDataTable List_BouncePoints; List_BouncePoints = BBDGQ.GetDataBySymbol(dgr_symbol); BounceChart.Series[0].Points.Clear(); BounceChart.Series[0].Name = dgr_symbol; //BounceGraph.Series[0].Points.Clear(); Form_BounceGraph_DT.Clear(); for (int i = 1; i < List_BouncePoints.Rows.Count; i++) { gvb_TodaysPrice = List_BouncePoints.Rows[i].Field <double>("open"); gvb_Tickerid = List_BouncePoints.Rows[i].Field <int>("TickerID"); gvb_Date = List_BouncePoints.Rows[i].Field <string>("date"); BounceChart.Series[0].Points.AddXY(i, gvb_TodaysPrice); // Here I want to run through the same logic the bounce process did when looking up all symbols. // Then display the bounced days in the Bouncegraph chart. gvb_Look.SetPricePoint(gvb_Tickerid, gvb_TodaysPrice, gvb_Date); // Check to see if a bounce was recorded. if (gvb_Look.sa_PriceBounces > gvb_counter) { gvb_counter = gvb_Look.sa_PriceBounces; dr = Form_BounceGraph_DT.NewRow(); dr["DropDate"] = gvb_Look.sa_DropDate; dr["GraphDays"] = Convert.ToString(Math.Min(BG_Detail.i_gmax, gvb_Look.sa_BounceDay[gvb_counter])); dr["RecoverDays"] = Convert.ToString(gvb_Look.sa_BounceDay[gvb_counter]); dr["Price"] = Convert.ToString(gvb_Look.sa_PricePoint); dr["DropPct"] = gvb_Look.sa_DropPct; dr["TickerID"] = Convert.ToString(gvb_Tickerid); Form_BounceGraph_DT.Rows.Add(dr); } } // Set the row after everything is full. BG_Detail.i_Rows = gvb_Look.sa_PriceBounces; BG_Detail.Set_Boundary(); BounceGraph.DataSource = Form_BounceGraph_DT; BounceGraph.Series["Days"].XValueMember = "DropDate"; BounceGraph.Series["Days"].YValueMembers = "GraphDays"; BounceGraph.DataBind(); } }