Step 1: Click New Project, then select Visual C# on the left, then Windows and then select Windows Forms Application. Name your project "StockChart" and then click OK
Step 2: Create a local database, then add a stock table to your database -> create a dataset then drag the stock table to your dataset as below

Step 3: Design your form as below

Step 4: Add code to handle your form as below
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace StockChart
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'database.Stocks' table. You can move, or remove it, as needed.
this.stocksTableAdapter.Fill(this.database.Stocks);
}
private void btnSave_Click(object sender, EventArgs e)
{
try
{
stocksBindingSource.EndEdit();
stocksTableAdapter.Update(database.Stocks);
dataGridView.Refresh();
MessageBox.Show("Your data has been successfully saved.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void btnLoad_Click(object sender, EventArgs e)
{
//Clear Grid
chart.ChartAreas["ChartArea1"].AxisX.MajorGrid.LineWidth = 0;
chart.ChartAreas["ChartArea1"].AxisY.MajorGrid.LineWidth = 0;
//Init
chart.Series["Daily"].XValueMember = "Day";
chart.Series["Daily"].YValueMembers = "High,Low,Open,Close";
chart.Series["Daily"].XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Date;
chart.Series["Daily"].CustomProperties = "PriceDownColor=Red,PriceUpColor=Blue";
//chart.Series["Daily"]["OpenCloseStyle"] = "Triangle";
chart.Series["Daily"]["ShowOpenClose"] = "Both";
chart.DataManipulator.IsStartFromFirst = true;
chart.DataSource = database.Stocks;
chart.DataBind();
}
}
}
VIDEO TUTORIALS