Category Archives: miscellany

How to use the examples at C# Helper

First, read over the text and the code shown on the web page. If you only need a small piece of code, that may be all you need. For example, if you don’t remember how to draw lines with custom … Continue reading

Posted in example program, miscellany | Tagged , , , , , , , | Leave a comment

Make a scrolled window in C#

Making a scrolled window is really easy, at least if you’ve seen how to do it before. If you haven’t seen it, you can spend a lot of time building your own scrolled window out of PictureBox, VerticalScrollBar, and HorizontalScrollBar … Continue reading

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

How to send an SMS text message in C#

This example finishes the series showing how to make a C# program send an SMS (Short Message Service) message. You could use this technique to make a program monitor some sort of ongoing process and send you a message if … Continue reading

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

Anatomy of an example

Usually I have to think of example ideas myself, but sometimes someone asks me a question that leads to an interesting post. Occasionally the original question leads to a new idea, which leads to another idea, and so on. This … Continue reading

Posted in miscellany | Tagged , , , , , | 2 Comments

A quick note on error messages

I went to a local museum the other day and when the attendant scanned by membership card his computer said: Object not set to a reference of an object. Because we’re programmers, you and I know what that means (more … Continue reading

Posted in MessageBox, miscellany, user interface | Tagged , , , , , , , , , , , , , | 1 Comment

Determine whether a year is a leap year in C#

Detecting leap years is basically trivial because the DateTime data type provides an IsLeapYear method to do just this. The example uses the following code to display the leap years between the two entered dates. // List leap years between … Continue reading

Posted in miscellany, variables | Tagged , , , , , , , , , , | Leave a comment

Find .NET libraries for namespaces in C#

Some namespaces have names that nicely match their .NET libraries. For example, the System.Drawing namespace is defined in the System.Drawing library. Unfortunately a namespace’s name doesn’t always match the name of the .NET library that defines it. For example, the … Continue reading

Posted in .NET, miscellany | Tagged , , , , , , , , | Leave a comment

Run user-entered code that modifies the program’s form in C#

The example Run user-entered code in C# shows how you can compile and execute code entered at run time. That example simply displays a message box and returns a DialogResult indicating which button the user pressed. This example shows how … Continue reading

Posted in algorithms, miscellany, programs, reflection | Tagged , , , , , , , , , , , , , , , , | Leave a comment

Tip: Make parentheses matching more visible in C#

Recently someone asked me if there was a Visual Studio add-in that highlighted parentheses, brackets, and braces so it would be easier to tell which closing parenthesis matched which opening parenthesis. It turns out that Visual Studio already has a … Continue reading

Posted in coding, miscellany, tips | Tagged , , , , , , , , | 1 Comment

Use accelerators on labels and buttons in C#

To place an accelerator on a menu item, you put an ampersand in front of the letter in the menu item’s caption that you want to be the accelerator. At run time, the caption is displayed with the accelerator letter … Continue reading

Posted in miscellany, productivity | Tagged , , , , , , , , , , , | Leave a comment