# TX Text Control X8: Inserting Chart Controls

> TX Text Control X8 for Windows Forms supports inserting .NET DataVisualization Chart controls into documents via the new ChartFrame class, which manages positioning. A C# walkthrough loads XML data into a DataSet, binds it to a bar chart, and embeds the chart in the document.

- **Author:** Bjoern Meyer
- **Published:** 2012-08-02
- **Modified:** 2026-07-17
- **Description:** TX Text Control X8 for Windows Forms supports inserting .NET DataVisualization Chart controls into documents via the new ChartFrame class, which manages positioning. A C# walkthrough loads XML data into a DataSet, binds it to a bar chart, and embeds the chart in the document.
- **3 min read** (402 words)
- **Tags:**
  - Release
  - Sample
- **Web URL:** https://www.textcontrol.com/blog/2012/08/02/tx-text-control-x8-inserting-chart-controls/
- **LLMs URL:** https://www.textcontrol.com/blog/2012/08/02/tx-text-control-x8-inserting-chart-controls/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2012/08/02/tx-text-control-x8-inserting-chart-controls/llms-full.txt

---

![TX Text Control X8](https://s1-www.textcontrol.com/assets/dist/blog/2012/08/02/a/assets/dotnet.webp "TX Text Control X8")**TX Text Control .NET for Windows Forms X8** now supports the insertion of chart controls of the type [DataVisualization.Charting.Chart](http://msdn.microsoft.com/en-us/library/system.windows.forms.datavisualization.charting.chart.aspx). It is part of the .NET Framework since version 4.0, but can be added to prior versions as well.

A chart can be positioned like an image or textframe, either geometrically or as a single character.

The new [ChartFrame](https://docs.textcontrol.com/textcontrol/windows-forms/ref.txtextcontrol.datavisualization.chartframe.class.htm) class handles the positioning of the chart in a document. Such a ChartFrame is always associated with a Chart control that handles the appearance and the data of the chart.

![TX Text Control Charts](https://s1-www.textcontrol.com/assets/dist/blog/2012/08/02/a/assets/tx_x8_charts.webp "TX Text Control Charts")The goal in this sample is to insert a bar chart filled with XML data into a document. The following XML data should be used:

```
<?xml version="1.0" encoding="utf-8" ?>
<sales>
    <points>
      <country>Country 1</country>
      <value>100</value>
    </points>
    <points>
      <country>Country 2</country>
      <value>120</value>
    </points>
    <points>
      <country>Country 3</country>
      <value>80</value>
    </points>
</sales>
```

In order to insert a chart diagram into the document, we need to create a new chart. Make sure that a reference to *System.Windows.Forms.DataVisualization.Charting.Chart* has been added to your project.

Each chart object needs a [ChartArea](http://msdn.microsoft.com/en-us/library/system.web.ui.datavisualization.charting.chartarea.aspx) that represents a chart area on the chart image and a [Series](http://msdn.microsoft.com/en-us/library/system.web.ui.datavisualization.charting.series) object that is connected to that area.

```
Chart chart = new Chart();
chart.ChartAreas.Add("chartArea1");
chart.Series.Add("series1");

// set the ChartType
chart.Series["series1"].ChartArea = "chartArea1";
chart.Series["series1"].ChartType = SeriesChartType.Bar;
```

In a next step, we can load the XML into a DataSet. The column names are used to set the member of the chart data source used to bind the X and Y values of the series.

```
DataSet ds = new DataSet();
ds.ReadXml("data.xml");

chart.Series[0].XValueMember = ds.Tables[0].Columns[0].ColumnName;
chart.Series[0].YValueMembers = ds.Tables[0].Columns[1].ColumnName;
```

Finally, the first table of the DataSet is specified as the data source for the Chart object. A new ChartFrame is created and inserted into the Charts collection of TX Text Control.

```
chart.DataSource = ds.Tables[0];
chart.DataBind();

ChartFrame chartFrame = new ChartFrame(chart);
textControl1.Charts.Add(chartFrame, -1);
```

---

## About Bjoern Meyer

As CEO, Bjoern is the visionary behind our strategic direction and business development, bridging the gap between our customers and engineering teams. His deep passion for coding and web technologies drives the creation of innovative products. If you're at a tech conference, be sure to stop by our booth - you'll most likely meet Bjoern in person. With an advanced graduate degree (Dipl. Inf.) in Computer Science, specializing in AI, from the University of Bremen, Bjoern brings significant expertise to his role. In his spare time, Bjoern enjoys running, paragliding, mountain biking, and playing the piano.

- [LinkedIn](https://www.linkedin.com/in/bjoernmeyer/)
- [X](https://x.com/txbjoern)
- [GitHub](https://github.com/bjoerntx)

---

## Related Posts

- [Fresh from Our Labs: Adobe PDF Import Improvements](https://www.textcontrol.com/blog/2012/05/09/fresh-from-our-labs-adobe-pdf-import-improvements/llms.txt)
- [Updating TX Text Control](https://www.textcontrol.com/blog/2005/06/23/updating-tx-text-control/llms.txt)
- [TX Text Control 34.0 SP4 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2026/05/20/tx-text-control-34-0-sp4-is-now-available/llms.txt)
- [TX Spell .NET 11.0 SP1 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2026/04/08/tx-spell-net-11-0-sp1-is-now-available/llms.txt)
- [Announcing TX Text Control DS Server 5.0](https://www.textcontrol.com/blog/2026/03/12/announcing-tx-text-control-ds-server-5-0/llms.txt)
- [TX Text Control 34.0 SP2 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2026/02/18/tx-text-control-34-0-sp2-is-now-available/llms.txt)
- [TX Text Control 34.0 SP1 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2025/12/03/tx-text-control-34-0-sp1-is-now-available/llms.txt)
- [Introducing TX Text Control 34.0: Your Next Leap in Document Processing](https://www.textcontrol.com/blog/2025/11/10/introducing-tx-text-control-34-0-your-next-leap-in-document-processing/llms.txt)
- [PDF/UA vs. PDF/A-3a: Which Format Should You Use for Your Business Application?](https://www.textcontrol.com/blog/2025/10/24/pdf-ua-vs-pdf-a-3a-which-format-should-you-use-for-your-business-application/llms.txt)
- [Validating PDF/UA Documents in .NET C#](https://www.textcontrol.com/blog/2025/10/21/validating-pdf-ua-documents-in-dotnet-csharp/llms.txt)
- [Sneak Peek: TX Text Control 34.0 Coming November 2025](https://www.textcontrol.com/blog/2025/10/02/sneak-peek-tx-text-control-34-0-coming-november-2025/llms.txt)
- [TX Text Control 33.0 SP3 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2025/08/14/tx-text-control-33-0-sp3-is-now-available/llms.txt)
- [High-Performance Text Replacement in Large DOCX Files using C# .NET](https://www.textcontrol.com/blog/2025/07/30/high-performance-text-replacement-in-large-docx-files-using-csharp-dotnet/llms.txt)
- [Document Viewer 33.2.1 Released: New Event and Bug Fixes](https://www.textcontrol.com/blog/2025/07/30/document-viewer-33-2-1-released-new-event-and-bug-fixes/llms.txt)
- [Upcoming Support for PDF/UA Compliance and Tagged PDF Generation in Version 34.0](https://www.textcontrol.com/blog/2025/07/24/upcoming-support-for-pdf-ua-compliance-and-tagged-pdf-generation-in-version-34-0/llms.txt)
- [TX Text Control 33.0 SP2 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2025/06/18/tx-text-control-33-0-sp2-is-now-available/llms.txt)
- [Service Pack Releases: What's New in TX Text Control 33.0 SP1 and 32.0 SP5](https://www.textcontrol.com/blog/2025/05/07/service-pack-releases-whats-new-in-tx-text-control-33-0-sp1-and-32-0-sp5/llms.txt)
- [Introducing DS Server 4.0: Linux-Ready and Container-Friendly](https://www.textcontrol.com/blog/2025/04/30/introducing-ds-server-4-linux-ready-and-container-friendly/llms.txt)
- [The Wait is Over: TX Text Control for Linux is Officially Here](https://www.textcontrol.com/blog/2025/03/12/the-wait-is-over-tx-text-control-for-linux-is-officially-here/llms.txt)
- [Full .NET 9 Support in Text Control .NET Components for ASP.NET Core, Windows Forms, and WPF](https://www.textcontrol.com/blog/2024/11/11/full-net-9-support-in-text-control-net-components-for-asp-net-core-windows-forms-and-wpf/llms.txt)
- [DS Server 3.5.0 Released](https://www.textcontrol.com/blog/2024/09/24/ds-server-3-5-0-released/llms.txt)
- [Using the Document Editor in SPA Applications using the removeFromDom Method](https://www.textcontrol.com/blog/2024/09/02/using-the-document-editor-in-spa-applications-using-the-removefromdom-method/llms.txt)
- [TX Text Control 32.0 Service Pack 4 Released](https://www.textcontrol.com/blog/2024/09/02/tx-text-control-32-0-service-pack-4-released/llms.txt)
- [Service Pack 3: MailMerge Supports SVG Images](https://www.textcontrol.com/blog/2024/04/29/service-pack-3-mailmerge-supports-svg-images/llms.txt)
- [TX Text Control 32.0 Service Pack 3 Released](https://www.textcontrol.com/blog/2024/04/29/tx-text-control-32-0-service-pack-3-released/llms.txt)
