0
將ListArray綁定到C#(VS2015)中的燭臺圖表時遇到問題。我一直在我的桌子上敲着我的頭一天...現在有時間問。 :)在我看來,圖表類真的想綁定到數據庫。我希望能夠生成少量的股票數據,然後將其推入燭形圖表。 我的代碼:將ListArray數據類型綁定到燭臺圖表系列
public class Record
{
int id;
string time_stamp;
double open, close, high, low;
public Record(int id, string time_stamp, double open, double close, double high, double low)
{
this.id = id;
this.open = open;
this.close = close;
this.high = high;
this.low = low;
}
public int ID
{
get { return id; }
set { id = value; }
}
public string TimeStamp
{
get { return time_stamp; }
set { time_stamp = value; }
}
public double Open
{
get { return open; }
set { open = value; }
}
public double Close
{
get { return close; }
set { close = value; }
}
public double High
{
get { return high; }
set { high = value; }
}
public double Low
{
get { return low; }
set { low = value; }
}
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
ArrayList listDataSource = new ArrayList();
//add some members to list
listDataSource.Add(new Record(1, "4 oclock", 10, 5, 7, 8));
listDataSource.Add(new Record(1, "5 oclock", 11, 4, 4, 9));
chart1.Series["Series1"].XValueMember = "Time";
chart1.Series["Series1"].YValueMembers = "High, Low, Open, Close";
chart1.Series["Series1"].CustomProperties = "PrieceDownColor=Red,PriceUpColor=green";
chart1.Series["Series1"]["ShowOpenClose"] = "Both";
chart1.DataManipulator.IsStartFromFirst = true;
chart1.DataSource = listDataSource;
chart1.DataBind(); // fails to bind
}
}
幫助!
感謝趕上那裏。它現在運行。但是,系列1不顯示在圖表上。 – Chipcraft
@Chipcraft我已經更新了截圖和工作代碼。希望有所幫助。 –
謝謝亞當!這是完美的。我發現這些視覺工作室的文檔相當缺乏。 – Chipcraft