O'Reilly logo

Pro C# 2010 and the .NET 4 Platform, Fifth Edition by Andrew Troelsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

18.5. COM Interop using C# 4.0 Language Features

Assume you have a Windows Form GUI application (named ExportDataToOfficeApp), whose main Form defines a DataGridView named dataGridCars. This same form has two Button controls, one of which will bring up a dialog box to insert a new row of data to the grid, and the other of which needs to export the grid's data to an Excel spreadsheet. Given the fact that the Excel application exposes a programming model via COM, you can hook into this object model using the interoperability layer. Figure 18-9 shows the completed GUI.

Figure 18.9. The GUI of the COM interop example

You will fill the grid with ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required