Visual Studio 2010 – The Windows Forms is not death – The Chart Control

Bosanska verzija teksta može se pročitati ovdje.

With releasing the WPF platform, there are good reasons and questions of what will happen with WindowsForms platform.The official said, for this platform are promising and there is no concern, and it will be continue to develop. Needles to say that the WindowsForms is the most common platform. The News coming from the new version of VS 2010 confirm this fact, and this post will be exactly related to new features in WindowsForms. With the new version of Visual Studio 2010 there is a new control: Char Control clip_image002.

This control is located in the System.Windows.Forms.DataVisualization namespace. Looking thought the ObjectBrowser, there is only one control. Probably they will be more in the future.


Chart control has support for connecting to external data source, which means that we can use and connect it directly to database, through one of the existing ORM maper (DataSet, LINQtoSQL or EF). In this post, we will make a simple example with applying the Chart control.

At the beginning let’s create Windows Forms application via File-> New -> Project.


Create EF model for the Northwind database, with standard tables: Orders and Order_Details.


In fact, when you open the Form1 and show the DataSources window, our tables are shown, but the designer does not allow us to drag and drop them in to the form (see picture below).


In order to use the DataSources designer window, we need to add these tables as objects of the DataSources. For this purpose choose Add New DataSource button, then choose Object item and choose Next button (see picture below).


Then in the next window, select our Tables and finish the wizard.


DataSources window now looks like the following picture:


We got two new items that can drag on Form1. Drag and drop the DataGrid objects in Form1, and add Chart control from ToolBox as shown in the following picture:


Since the DataGrid controls are already connected to bindingsource, it is now necessary to connect the Chart control with Order_Details table. To show data in the graph we need associate columns Quantity and UnitPrice with the chart control members.

To achieve this, it is neccessery chart1.Datasource apply with orders_detailsBidningSource.


When we apply the data source to the chart control, we are now able to set how data will be presented.Chart control has a Series property, and within Series property you can find properties for displaying data in X and Y axes (see picture below).


With this we finished setting up Chart control.

It is now necessary to load data from the database. Open the Form1.cs file, implement the events Form_Load and ListChanged, similar on the picture below.


We see that we have set up two events for the Form1 Load event and ListChanged event for order_DetailsBidnigSource. The second event is necessary to refresh the Chart control.

If you run the project, the result is similar to the following picture.


When we change the current row Order table, changes the content is below the table, as well as in the chart control. This example, we implemented Master-Detail relationship with two DataGrid and one Chart control.


14 thoughts on “Visual Studio 2010 – The Windows Forms is not death – The Chart Control

  1. Pingback: GPdotNET with new chart control « Bahrudin Hrnjica Blog

  2. Thank you for those instructions but I have an issue. I’ve been looking to use this control since a long time for a university project but unfortunately I don’t see this control in the toolbox; and I mean anywhere in the toolbox (I’ve inspected every section). How can I make it appear. All the chart controls I have found online relate to VS2008. I am using VS2010.

  3. I am no professional prarmomger, but as an amater I wrote a blog post () where, as the title suggest, I recommended 9 programming books. And our intersection is 0. Odd! But eyeing your list, it is pretty clear we have different coding interests . Although I have to admit that 2 or 3 of the books you highlight seem pretty interesting!Ruben

  4. , an innovative, young and promising company that was founded in 2004 by two creative and
    enthusiastic young programmers. smartphones, i – Phones and
    i – Pods and even i – Pads and tablets in both
    touch screen and handheld mode. While the public may not be as important
    as users of i – Phone, Android looks like a serious candidate, just because of the

  5. Yesterday, while I was at work, my cousin stole
    my iphone and tested to see if it can survive a thirty foot
    drop, just so she can be a youtube sensation. My iPad
    is now broken and she has 83 views. I know
    this is totally off topic but I had to share it with

  6. Now a days we can find there are numerous online
    games available for children to play with. Another classic toy available from the app
    store which is the amazing Etch A Sketch. It successfully combines both puzzle and adventure niches, being
    the ideal app for those who wish to evade daily.

  7. This is really interesting, You are a very skilled blogger.

    I’ve joined your feed and look forward to seeking more of your fantastic post.
    Also, I’ve shared your site in my social networks!

  8. If you look closer, you will notice them surfing in a flirt chat room.
    One thing I have wanted for a long time that seems to not be an option here on examiner.

    All you need to do is a simple research and simply stop at the ones that attract you.

  9. Good day! This post could not be written any better!
    Reading through this post reminds me of my previous room mate!
    He always kept chatting about this. I will forward this page
    to him. Pretty sure he will have a good read. Thank you for sharing!

  10. Hello admin, i must say you have hi quality content here.
    Your blog should go viral. You need initial traffic only.
    How to get it? Search for: Mertiso’s tips go

  11. I have checked your website and i’ve found some duplicate
    content, that’s why you don’t rank high in google, but there
    is a tool that can help you to create 100% unique content, search for: Boorfe’s tips unlimited content

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s