Tag Archives: example

Delete files quickly and easily in C#

A while ago, I needed to delete files that were created when I opened old projects in a newer version of Visual Studio. LOTS of files. (As far as I know, there’s no way to tell Visual Studio not to … Continue reading

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

Understand the startup form (or main form) in C#

When a C# Windows Forms program starts, it displays a startup form. That form has a special place in the program’s life cycle. If that form ever closes, the application ends. The program can create and close as many other … Continue reading

Posted in forms, user interface | Tagged , , , , , , , , | Leave a comment

Find a form’s screen in C#

Find a form’s screen can be an issue if the user is using more than one monitor. When this program starts, it uses the following code to get the Screen object that holds the form and display its device name, … Continue reading

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

Position a form so it does not stick off the edge of the screen in C#

In the picture, the main program (on the bottom) initially positioned the top form so it was hanging off the right and bottom edges of the screen. The program’s code moved the form so it fit in the screen’s lower … Continue reading

Posted in forms, user interface | Tagged , , , , , , , , | Leave a comment

Position a form over another form in C#

When you click this example’s button, the program uses the following code to display a new instance of the main form positioned next to the button’s lower left corner (as shown in the picture). // Position a new instance of … Continue reading

Posted in forms, user interface | Tagged , , , , , , , , , | Leave a comment

Use Debug and Trace listeners in C#

By default, the Debug and Trace classes send messages to the Console window. Sometimes it might be nice to capture that text and save it in a file. This example shows how you can do that. The Debug and Trace … Continue reading

Posted in debugging | Tagged , , , , , , , , , , , | Leave a comment

Use branch and bound to find the highest value path through a two-dimensional array of numbers in C#

This method is similar to path-finding methods described in my books Essential Algorithms: A Practical Approach to Computer Algorithms and Interview Puzzles Dissected, Solving and Understanding Interview Puzzles. Follow those links for more information including tables of contents. The example … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , , , , | Leave a comment

Find the highest value path through a two-dimensional array of numbers in C#

This method is similar to path-finding methods described in my books Essential Algorithms: A Practical Approach to Computer Algorithms and Interview Puzzles Dissected, Solving and Understanding Interview Puzzles. Follow those links for more information including tables of contents. Look at … Continue reading

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

Save Excel data in a PDF file in C#

This example extends the example Write Excel data in C#. See that example for information on how to open an Excel workbook, write data into it, and save it. Note that before you can use the Excel interop library, you … Continue reading

Posted in Excel, Office | Tagged , , , , , , , , , , | 1 Comment

Load a cursor from a resource in C#

Sometimes it’s useful to use a non-standard cursor in a program. This example explains how you can load a cursor from a cursor file included as a project resource. To add a cursor file to the project’s resources, open the … Continue reading

Posted in files, graphics | Tagged , , , , , , , , , , , | Leave a comment