Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to bind data to chart in winforms and refresh chart?

I tried to bind chart to generatedSequence of type List<float>. How to update chart control after binding?

I tried this but with no luck:

chart1.DataSource = new BindingList<float>(chartSequence);
chart1.DataBind();

chart1.Update();
like image 639
testCoder Avatar asked Jan 15 '13 21:01

testCoder


People also ask

What is Data Binding in Winforms?

Simple data binding is the type of binding typical for controls such as a TextBox control or Label control, which are controls that typically only display a single value. In fact, any property on a control can be bound to a field in a database. There's extensive support for this feature in Visual Studio.

How chart control is used in asp net?

The ASP.NET Chart Control provides flexible data binding options that allow you to bind to a table from a database or a collection created in code. The control also includes a built-in chart wizard that is invoked at design time, to assist in chart configuration.


1 Answers

Don't forget set DataSource property of Series in chart property.

enter image description here

Set XValueMember and YValueMembers from code:

chart1.Series.First().XValueMember = "X";
chart1.Series.First().YValueMembers = "Y";

Tutorial: Creating a Basic Chart

like image 85
kmatyaszek Avatar answered Oct 07 '22 23:10

kmatyaszek