Monthly Archives: September 2013

Remove unnecessary “using” directives in C#

The top of a C# code file often includes series of “using” directives to tell Visual Studio which namespaces are used by the code. When you first create a project, the code files include lots of using directives that might … Continue reading

Posted in coding, performance | Leave a comment

Use XML “literals” in C#

Visual Basic has XML literals so you can include them directly in your code as in the following example. Dim employees As XElement = <employees> <employee firstname=”Terry” lastname=”Pratchett”/> <employee firstname=”Glen” lastname=”Cook”/> <employee firstname=”Tom” lastname=”Holt”/> <employee> <firstname>Rod</firstname> <lastname>Stephens</lastname> </employee> </employees> C# … Continue reading

Posted in strings, XML | Leave a comment

Use VBA macros to add and remove hyperlinks to external PowerPoint and Word files in C#

My book Essential Algorithms: A Practical Approach to Computer Algorithms has associated instructor materials that include lesson plans and PowerPoint presentations. There’s also a summary Excel workbook. In the workbook, column C contains links to lesson plans (Word documents) and … Continue reading

Posted in Excel, Office, PowerPoint, Word | Leave a comment

Make a ListView control display icons next to sub-items in C#

This example makes a ListView control display icons next to the sub-items in its Detail View. This requires two steps beyond what is required to make a ListView display item icons: (1) assigning image indices to the sub-items and (2) … Continue reading

Posted in controls | 1 Comment

Make a ListView control display large and small icons in C#

The ListView control displays two sizes of icons for its items. When its View property is LargeIcon or Tile, the control displays large icons. When the View property is SmallIcon, List, or Details, the control displays small icons. The control … Continue reading

Posted in controls | 2 Comments

Get assembly information in C#

If you open the Project menu and select Properties, Visual Studio displays the project’s property pages. If you then select the Application tab and click the Assembly Information button, you see the dialog shown above. Here you can set various … Continue reading

Posted in settings, system | Leave a comment

Use a StringFormat object to align text in columns drawn on a window in C#

My previous post showed how to draw tab-delimited text in columns. Unfortunately that method doesn’t give you control over how the values in each column are aligned. This example uses the following code to draw text in columns that can … Continue reading

Posted in fonts, graphics, strings | Leave a comment

Use tabs and a StringFormat object to align text drawn on a window in C#

The Graphics class’s DrawString method draws a string on a window, PictureBox, Bitmap, or other drawing surface. DrawString has several overloaded versions, some of which take a StringFormat object as a parameter. That object lets you define things such as … Continue reading

Posted in fonts, graphics, strings | Leave a comment

Make an application with skins in C#, Part 2 (the code)

My previous post explained the controls that this example uses to let you give a form a skin. Basically an arrangement of Panels and PictureBoxes with the Dock properties set appropriately display the form’s edge and corner images. If you … Continue reading

Posted in user interface | Leave a comment

Make an application with skins in C#, Part 1 (the controls)

Skinned applications are just plain cool. By setting a Windows Form’s TransparencyKey property to a color that should not be rendered, you can make a form with a distinctive shape. That’s a good start but it has several drawbacks. In … Continue reading

Posted in user interface | Leave a comment