Tag Archives: C# programming

Display tooltips for TreeView nodes in C#

At design time, I added a TreeView control to the form. I also added an associated ImageList control to hold images for the TreeView control’s nodes, and I set the TreeView control’s ImageList property to the ImageList control. Finally I … Continue reading

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

Compare sorting algorithms in C#, article 5 of 5

Countingsort The discussion of Quicksort in my previous post mentions that the fastest possible sorting algorithms that use comparisons take on the order of N * log(N) steps. Countingsort does not use comparisons so it is not bound by that … Continue reading

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

Compare sorting algorithms in C#, part 4 of 5

Quicksort Quicksort is a recursive algorithm that uses a divide-and-conquer technique. While the list of items to be sorted contains at least two items, Quicksort divides it into two sublists and recursively calls itself to sort the sublists. The Quicksort … Continue reading

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

Compare sorting algorithms in C#, part 3 of 5

Selectionsort Selectionsort is a very simple algorithm. First you search the list for the smallest item. Then you swap that item with the item at the top of the list. Next you find the second smallest item and swap it … Continue reading

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

Compare sorting algorithms in C#, part 2 of 5

Bubblesort Bubblesort is a specialized algorithm designed for sorting items that are already mostly in sorted order. If only one or two items in your list are out of order, Bubblesort is very fast. If the items in your list … Continue reading

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

Compare sorting algorithms in C#, post 1 of 5

This post begins a series of articles about sorting algorithms. Much of the text originally appeared in the December 1995 issue of Visual Basic Developer magazine, a publication that seems to no longer exist. All of these posts include the … Continue reading

Posted in algorithms, performance | Tagged , , , , , , , , , , , , , , | 6 Comments

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

Use the yield statement in C#

An enumeration is a sequence of values that a program can enumerate over, for example, by using a foreach loop. In C# you can use the yield statement to make a method that returns an enumeration. The method that builds … Continue reading

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

Understand AutoScaleMode in C#

A form’s AutoScaleMode property lets a form automatically resize itself when its font changes. This can be particularly useful with an aging user population that may have trouble seeing smaller fonts. To try to help users out, you can give … Continue reading

Posted in fonts, forms, graphics | Tagged , , , , , , , , , , | 1 Comment

Draw transformed text in C#

This example uses the following Paint event handler to draw transformed text. // Draw some transformed text. private void Form1_Paint(object sender, PaintEventArgs e) { // Transform. e.Graphics.ScaleTransform(1.5f, 1.5f, MatrixOrder.Append); e.Graphics.RotateTransform(25, MatrixOrder.Append); e.Graphics.TranslateTransform(80, 30, MatrixOrder.Append); // Make a font. using (Font … Continue reading

Posted in drawing, fonts, graphics | Tagged , , , , , , , , , | 2 Comments