private void DrawToChart() { int top = (int)numTop.Value; top = (dataGridView1.Rows.Count < top) ? dataGridView1.Rows.Count : top; string[] titles = new string[top]; int[] values = new int[top]; DataGridViewRowCollection rows = dataGridView1.Rows; Series s = chart1.Series[0]; s.Points.Clear(); for (int i = 0; i < top; i++) { SaleOutInfo sale = rows[i].Tag as SaleOutInfo; string name = rows[i].Cells[0].Value.ToString(); s.Points.AddXY(name, sale.GetRevenue()); s.Points[i].Label = NumberToStringWithSuffix(sale.GetRevenue()); } }
private void SetDataToGrid(List <SaleOutInfo> saleOutInfos) { dataGridView1.Rows.Clear(); for (int i = 0; i < saleOutInfos.Count; i++) { SaleOutInfo s = saleOutInfos[i]; int index = dataGridView1.Rows.Add(MenuView.ProductsList[s.ProductID].Name + i.ToString(), s.NumberOfProduct, s.GetRevenue()); dataGridView1.Rows[index].Tag = s; dataGridView1.Rows[index].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; } numTop.Maximum = dataGridView1.Rows.Count; }