New to Telerik UI for WinFormsStart a free 30-day trial

Binding to DataTable

Updated over 6 months ago

Binding to DataTable is quite easy with RadChartView. Once your table is created, you just need to set the needed members to the desired fields. In this article , you can find the members needed for the different series types.

Here is a sample demonstrating how to bind а LineSeries:

Binding to DataTable

C#
DataTable table;
protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);
    table = new DataTable();
    table.Columns.Add("Value", typeof(double));
    table.Columns.Add("Name", typeof(string));
    table.Rows.Add(1, "John");
    table.Rows.Add(3, "Adam");
    table.Rows.Add(5, "Peter");
    table.Rows.Add(12, "Sam");
    table.Rows.Add(6, "Paul");
    LineSeries lineSeria = new LineSeries();
    radChartView1.Series.Add(lineSeria);
    lineSeria.ValueMember = "Value";
    lineSeria.CategoryMember = "Name";
    lineSeria.DataSource = table;
}

Figure 1: Binding to DataTable

WinForms RadChartView Binding to DataTable

Adding, removing or modifying a record in the DataTable is automatically reflected in RadChartView:

Figure 2: Modify Item

WinForms RadChartView Modify Item

See Also

In this article
See Also
Not finding the help you need?
Contact Support