Nevron .NET Vision
Chart for .NET / Getting Started / Integrating in Windows Forms / Integrating in Windows Forms

In This Topic
    Integrating in Windows Forms
    In This Topic

    This topic describes the steps necessary to build a simple Windows Forms application using Nevron Chart for .NET.

    1. Open Microsoft Visual Studio .NET.

    2. On the File / New Project select "Visual C# projects" and then select "Windows application" from the list on the right side.

    VS 2010 users must switch the target framework to ".NET Framework 4" as by default Windows Forms applications target ".NET Framework 4 Client Profile". This is required, because Nevron Chart for WinForms uses design time support features that are not present in ".NET Framework 4 Client Profile". To do this right click on the project in Solution Explorer and select properties. On the Application tab go to "Target Framework" and select ".NET Framework 4".

    4. [Optional] Change the application name from WindowsApplication[n] to NChartTest.

    5. Click OK.

    6. Open the Toolbox. If it's not visible open it from the View\Toolbox menu item.

    7. Locate the Nevron Chart Win Form tab and expand it.

    8. Drag and drop the NChartControl item on the form.

    9. Start the application. The form must display an empty chart.

    10. Close the application and then open the source code for Form1.cs. Double click on the form - VS should open the source code and automatically create the Form1_Load event handler.

    11. Add the following lines in the beginning of the file:

    C#
    Copy Code
    using Nevron.GraphicsCore;
    using Nevron.Chart;
    using Nevron.Chart.WinForm;
    using Nevron.Chart.Windows;
    
    
    
        
    Visual Basic
    Copy Code
    Imports Nevron.GraphicsCore 
    Imports Nevron.Chart
    Imports Nevron.Chart.WinForm
    Imports Nevron.Chart.Windows 
    

    12. In the Form1_Load function insert the following code:

    C#
    Copy Code
    nChartControl1.Controller.Tools.Add(new NSelectorTool());
    nChartControl1.Controller.Tools.Add(new NTrackballTool());
    
    NPieChart chart = new NPieChart();
    nChartControl1.Charts.Clear();
    nChartControl1.Charts.Add(chart);
    chart.Enable3D = true;
    chart.Width = 70;
    chart.Depth = 10;
    chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveElevated);
    chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.ShinyCameraLight);
    
    NPieSeries pie = (NPieSeries)chart.Series.Add(SeriesType.Pie);
    pie.PieStyle = PieStyle.SmoothEdgePie;
    pie.LabelMode = PieLabelMode.SpiderNoOverlap;
    
    pie.AddDataPoint(new NDataPoint(12, "Cars"));
    pie.AddDataPoint(new NDataPoint(42, "Trains"));
    pie.AddDataPoint(new NDataPoint(56, "Airplanes"));
    pie.AddDataPoint(new NDataPoint(23, "Buses"));
    pie.AddDataPoint(new NDataPoint(32, "Bikes"));
    pie.AddDataPoint(new NDataPoint(29, "Boats"));
    
    NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.NevronMultiColor);
    styleSheet.Apply(nChartControl1.Document);
    
    nChartControl1.Refresh();
    
    
    
        
    Visual Basic
    Copy Code
    nChartControl1.Controller.Tools.Add(New NSelectorTool())
    nChartControl1.Controller.Tools.Add(New NTrackballTool())
    
    Dim chart As NPieChart = New NPieChart()
    nChartControl1.Charts.Clear()
    nChartControl1.Charts.Add(chart)
    chart.Enable3D = True
    chart.Width = 70
    chart.Depth = 10
    chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveElevated)
    chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.ShinyCameraLight)
    
    Dim pie As NPieSeries = chart.Series.Add(SeriesType.Pie)
    pie.PieStyle = PieStyle.SmoothEdgePie
    pie.LabelMode = PieLabelMode.SpiderNoOverlap
    
    pie.AddDataPoint(new NDataPoint(12, "Cars"))
    pie.AddDataPoint(new NDataPoint(42, "Trains"))
    pie.AddDataPoint(new NDataPoint(56, "Airplanes"))
    pie.AddDataPoint(new NDataPoint(23, "Buses"))
    pie.AddDataPoint(new NDataPoint(32, "Bikes"))
    pie.AddDataPoint(new NDataPoint(29, "Boats"))
    
    Dim styleSheet As NStyleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.NevronMultiColor)
    styleSheet.Apply(nChartControl1.Document)
    
    nChartControl1.Refresh()
    
    13. Now start the application again - the page must display a simple pie chart.
    

    14. Congratulations - you've created your first Windows Forms application using Nevron Chart for .NET!