OAS Trend .NET Programmatic Methods
There are several different methods to programmatically access the trend data and call history for the trend OPCTrendControl. Refer to the OPCTrendControl help file for all properties and methods with their description and syntax.
Use the GetTrendDataTable method to return a DataTable of all data in the current view.
Get Trend History Data Programmatically
The following code can be used to programmatically get history data and return the data to a DataTable:
private void button1_Click(object sender, EventArgs e) { DateTime endTime = DateTime.Now; DateTime startTime = endTime.AddMinutes(-20); opcTrendControl1.HistorySelect(startTime, endTime); } private void opcTrendControl1_HistoryDataArrived() { DataTable myDataTable; myDataTable = opcTrendControl1.GetTrendDataTable(); dataGridView1.DataSource = myDataTable; }