Report 1 Example for WinForms

Nevron NOV RichTextEditor for WinForms ships with hundreds of examples with full source code, as part of the Nevron Open Vision Suite. All WinForms RichTextEditor examples are also available as a stand-alone Visual Studio solution in C# and VB.NET, which you can download from the links below.

Report 1 Example for WinForms Description

The example demonstrates how to programmatically create a sample report.


Sample Report 1Example

C# Report 1 Example Code for Nevron RichTextEditor for WinForms
Language: C#

using Nevron.Nov;
using Nevron.Nov.Chart;
using Nevron.Nov.Dom;
using Nevron.Nov.Graphics;
using Nevron.Nov.Layout;
using Nevron.Nov.Text;
using Nevron.Nov.UI;
using Nevron.Nov.Windows.Forms;
using System.Windows.Forms;

namespace NovWinFormsProject
{
	public partial class Form1 : Form
	{
		#region Constructors

		public Form1()
		{
			InitializeComponent();

			// Set form title
			Text = "NOV WinForms - NSampleReport1Example";

			// Create the NOV example and its controls
			NWidget exampleContent = CreateExampleContent();
			NWidget exampleControls = CreateExampleControls();
			if (exampleControls != null)
			{
				exampleControls.PreferredWidth = 300;
			}

			// Place the example and its controls in a pair box
			NPairBox pairBox = new NPairBox(exampleContent, exampleControls);
			pairBox.FillMode = ENStackFillMode.First;
			pairBox.FitMode = ENStackFitMode.First;
			pairBox.Margins = new NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing);

			// Host the example in the form
			NNovWidgetHost host = new NNovWidgetHost(pairBox);
			host.Dock = DockStyle.Fill;
			Controls.Add(host);
		}

		#endregion

		#region Example

		private NWidget CreateExampleContent()
		{
			return null;
		}
		private NWidget CreateExampleControls()
		{
			return null;
		}

		#endregion

		#region Implementation


		/// 
		/// Creates a table cell with border
		/// 
		/// 
		private NTableCell CreateTableCellWithBorder()
		{
			NTableCell tableCell = new NTableCell();

			tableCell.Border = NBorder.CreateFilledBorder(NColor.Black);
			tableCell.BorderThickness = new NMargins(1);

			return tableCell;
		}
		/// 
		/// Creates a section title paragraph
		/// 
		/// 
		/// 
		private NParagraph CreateTitleParagraph(string text)
		{
			NParagraph paragraph = new NParagraph();

			NTextInline textInline = new NTextInline();
			textInline.Text = text;
			textInline.FontSize = 14;
			textInline.Fill = new NColorFill(NColor.FromRGB(89, 76, 46));
			paragraph.Inlines.Add(textInline);

			return paragraph;
		}
		/// 
		/// Creates a content paragraph
		/// 
		/// 
		private NParagraph CreateContentParagraph(string text)
		{
			NParagraph paragraph = new NParagraph(text);

			paragraph.HorizontalAlignment = ENAlign.Justify;

			return paragraph;
		}
		/// 
		/// Creates a sample bar chart given title, values and labels
		/// 
		/// 
		/// 
		/// 
		/// 
		/// 
		private NParagraph CreateSampleBarChart(NSize size, string title, double[] values, string[] labels)
		{
			NChartView chartView = CreateCartesianChartView();

			chartView.PreferredSize = size;

			// configure title
			chartView.Surface.Titles[0].Text = title;
			chartView.Surface.Titles[0].Margins = NMargins.Zero;
			chartView.Surface.Legends[0].Visibility = ENVisibility.Hidden;
			chartView.BorderThickness = NMargins.Zero;

			// configure chart
			NCartesianChart chart = (NCartesianChart)chartView.Surface.Charts[0];
			chart.Padding = new NMargins(20);

			// configure axes
			chart.Margins = NMargins.Zero;

			NBarSeries bar = new NBarSeries();
			bar.LegendView.Mode = ENSeriesLegendMode.None;
			bar.DataLabelStyle = new NDataLabelStyle(false);

			chart.Series.Add(bar);

			for (int i = 0; i < values.Length; i++)
			{
				bar.DataPoints.Add(new NBarDataPoint(values[i]));
			}

			NOrdinalScale scaleX = (NOrdinalScale)chart.Axes[ENCartesianAxis.PrimaryX].Scale;
			scaleX.Labels.TextProvider = new NOrdinalScaleLabelTextProvider(labels);

			NParagraph paragraph = new NParagraph();

			NWidgetInline chartInline = new NWidgetInline();
			chartInline.Content = chartView;
			paragraph.Inlines.Add(chartInline);

			return paragraph;
		}

		protected NChartView CreateCartesianChartView()
		{
			NChartView chartView = new NChartView();

			chartView.Surface.CreatePredefinedChart(ENPredefinedChartType.Cartesian);

			return chartView;
		}

		#endregion

		#region Event Handlers


		#endregion

		#region Fields

		private NRichTextView m_RichText;

		#endregion

		#region Static Methods
		#endregion

		#region Constants
		#endregion

		#region Nested Types
		#endregion
	}
}

Download a fully functional C# (.cs) Report 1 Example for WinForms Solution

VB.NET Report 1 Example Code for Nevron RichTextEditor for WinForms
Language: VB.NET

Imports Nevron.Nov
Imports Nevron.Nov.Chart
Imports Nevron.Nov.Dom
Imports Nevron.Nov.Graphics
Imports Nevron.Nov.Layout
Imports Nevron.Nov.Text
Imports Nevron.Nov.UI
Imports Nevron.Nov.Windows.Forms

Public Class Form1

#Region "Constructors"

    Public Sub New()
        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.

        ' Set form title
        Text = "NOV WinForms - NSampleReport1Example"

        ' Create the NOV example and its controls
        Dim exampleContent As NWidget = CreateExampleContent()
        Dim exampleControls As NWidget = CreateExampleControls()
        If Not exampleControls Is Nothing Then
            exampleControls.PreferredWidth = 300
        End If

        ' Place the example and its controls in a pair box
        Dim pairBox As NPairBox = New NPairBox(exampleContent, exampleControls)
        pairBox.FillMode = ENStackFillMode.First
        pairBox.FitMode = ENStackFitMode.First
        pairBox.Margins = New NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing)

        ' Host the example in the form
        Dim host As NNovWidgetHost(Of NWidget) = New NNovWidgetHost(Of NWidget)(pairBox)
        host.Dock = DockStyle.Fill
        Controls.Add(host)
    End Sub


#End Region

#Region "Example"

    Private Function CreateExampleControls() As NWidget
        Return Nothing
    End Function

    Private Function CreateExampleContent() As NWidget
        Return Nothing
    End Function

#End Region

#Region "Implementation"


        ''' 
        ''' Creates a table cell with border
        ''' 
        ''' 
        Private Function CreateTableCellWithBorder() As NTableCell
            Dim tableCell As NTableCell = New NTableCell()

            tableCell.Border = NBorder.CreateFilledBorder(NColor.Black)
            tableCell.BorderThickness = New NMargins(1)

            Return tableCell
        End Function
        ''' 
        ''' Creates a section title paragraph
        ''' 
        ''' 
        ''' 
        Private Function CreateTitleParagraph(text As String) As NParagraph
            Dim paragraph As NParagraph = New NParagraph()

            Dim textInline As NTextInline = New NTextInline()
            textInline.Text = text
            textInline.FontSize = 14
            textInline.Fill = New NColorFill(NColor.FromRGB(89, 76, 46))
            paragraph.Inlines.Add(textInline)

            Return paragraph
        End Function
        ''' 
        ''' Creates a content paragraph
        ''' 
        ''' 
        Private Function CreateContentParagraph(text As String) As NParagraph
            Dim paragraph As NParagraph = New NParagraph(text)

            paragraph.HorizontalAlignment = ENAlign.Justify

            Return paragraph
        End Function
        ''' 
        ''' Creates a sample bar chart given title, values and labels
        ''' 
        ''' 
        ''' 
        ''' 
        ''' 
        ''' 
        Private Function CreateSampleBarChart(size As NSize, title As String, values As Double(), labels As String()) As NParagraph
            Dim chartView As NChartView = CreateCartesianChartView()

            chartView.PreferredSize = size

            ' configure title
            chartView.Surface.Titles(0).Text = title
            chartView.Surface.Titles(0).Margins = NMargins.Zero
            chartView.Surface.Legends(0).Visibility = ENVisibility.Hidden
            chartView.BorderThickness = NMargins.Zero

            ' configure chart
            Dim chart = CType(chartView.Surface.Charts(0), NCartesianChart)
            chart.Padding = New NMargins(20)

            ' configure axes
            chart.Margins = NMargins.Zero

            Dim bar As NBarSeries = New NBarSeries()
            bar.LegendView.Mode = ENSeriesLegendMode.None
            bar.DataLabelStyle = New NDataLabelStyle(False)

            chart.Series.Add(bar)

            For i = 0 To values.Length - 1
                bar.DataPoints.Add(New NBarDataPoint(values(i)))
            Next

            Dim scaleX As NOrdinalScale = chart.Axes(ENCartesianAxis.PrimaryX).Scale
            scaleX.Labels.TextProvider = New NOrdinalScaleLabelTextProvider(labels)

            Dim paragraph As NParagraph = New NParagraph()

            Dim chartInline As NWidgetInline = New NWidgetInline()
            chartInline.Content = chartView
            paragraph.Inlines.Add(chartInline)

            Return paragraph
        End Function

        Protected Function CreateCartesianChartView() As NChartView
            Dim chartView As NChartView = New NChartView()

            chartView.Surface.CreatePredefinedChart(ENPredefinedChartType.Cartesian)

            Return chartView
        End Function

#End Region

#Region "Event Handlers"


#End Region

#Region "Fields"

        Private m_RichText As NRichTextView

#End Region

#Region "Static Methods"
#End Region

#Region "Constants"
#End Region

#Region "Nested Types"
#End Region

End Class

Download a fully functional VB.NET (.vb) Report 1 Example for WinForms Solution