Monthly Archives: November 2014

Remove the hyperlinks from a Word document in C#

This example shows how you can remove the hyperlinks from a Word document. When you select text on a web page and paste it into a Word document, the result often contains hyperlinks that you don’t want. (Actually after you … Continue reading

Posted in files, Office, Word | Tagged , , , , , , , , , , , | Leave a comment

Find the tangent lines between a point and a circle in C#

Finding the tangent lines between a point and a circle isn’t too hard if you’re familiar with the example Determine where two circles intersect in C#. Consider the figure on the right. R is the radius of the circle. You … Continue reading

Posted in algorithms, geometry, graphics, mathematics | Tagged , , , , , , , , , , , , , | 1 Comment

Print a form or control in C#

This example shows how you can print a form or control in a C# program. Way back in the days of Visual Basic 6, there was a PrintForm method. It simply grabbed an image of the form and printed it. … Continue reading

Posted in controls, forms, printing | Tagged , , , , , , , , , , , , | Leave a comment

Force garbage collection in C#

This example shows how you can force garbage collection in C#. The .NET languages use a garbage collection scheme of memory management. There are a few weird details, but the basic process is this. When the application is running low … Continue reading

Posted in memory, system | Tagged , , , , , , , , , , , , , | Leave a comment

Handle DataGridView errors in C#

This example shows how you can handle DataGridView errors when you modify the data in the DataGridView control. The example Build a DataTable and bind it to a DataGridView in C# shows how to use a DataGridView control to display … Continue reading

Posted in controls, database | Tagged , , , , , , , , , , , , , , | 1 Comment

Build a DataTable and bind it to a DataGridView in C#

This example shows how you can build a DataTable and bind it to a DataGridView control. A DataTable is an in-memory representation of a relational database table. It can define columns of particular data types and even enforce uniqueness and … Continue reading

Posted in controls, database | Tagged , , , , , , , , , , , | 13 Comments

Bind a DataGrid to a DataSet holding multiple tables at runtime in C#

This example shows how you can bind a DataGrid control to a DataSet loaded from an MDB file at runtime. When the form loads, the following code builds the DataSet and binds it to the form’s DataGrid control. // The … Continue reading

Posted in controls, database | Tagged , , , , , , , , , , | 11 Comments

List OLE DB providers installed on the system in C#

This example shows how you can list OLE DB providers installed on the system. (I recently had to run an older program on a new system, and the provider used by the old program wasn’t installed. This example let me … Continue reading

Posted in database, system | Tagged , , , , , , , , , , | 1 Comment

Draw a labeled line graph that displays value tooltips in C#

This (fairly complicated) example maps between several different coordinate systems: The main graph is mapped from a coordinate space where 1900 ≤ x ≤ 2010 and 0 ≤ y ≤ 8000 to an area on the screen. Each data point … Continue reading

Posted in drawing, graphics, mathematics, transformations | Tagged , , , , , , , , , , , , , | 1 Comment

Map points between coordinate systems in C#

This example shows how you can easily map points between different coordinate systems. The Graphics object provides transformations that let you scale, translate, rotate, skew, and otherwise transform graphics as you draw them. One important use of these transformations is … Continue reading

Posted in algorithms, drawing, graphics, transformations | Tagged , , , , , , , , , , , , , , , , , , | 2 Comments