Archives

Archives / 2009 / September
  • Using a WPF StackPanel for Business Forms

    In WPF if you want to layout a typical business form like the one shown in Figure 1, most people would use a Grid control with rows and columns. However, you may also use a StackPanel control. While sometimes you might need the re-sizing capabilities of a Grid, you sometimes just need a fixed size. For a fixed-size form a StackPanel control can be a little easier and offers a little more flexibility.

  • Split Name into First and Last

    Not too long ago we received a text file of customer names. The problem with the file is it just had one field "Name". One of the requirements of our database application was to have a first name field and a last name field so our customer could search for their customers on either field. As a result we needed to take this text file and split out the data into the two fields from the one.

  • Date Handling Tip: Get the Month Name

    There are a lot of great date handling methods attached to the DateTime class in .NET. However, if you wish to get information such as the current month name, you will not find it in this class. The reason is because .NET needs to take into account local culture and languages. Thus, methods that return something that is specific to a language or a culture are placed under the System.Globalization namespace. As an example, below is the code you would need to write to return the month name as a string in any language.

  • Check if String is All Lower or All Upper Case

    Funny how sometimes there are so many ways to accomplish the same thing. In a project last week I needed to check if a user entered a sentence in all lower (or could have been upper) case. So I immediately went to the most simple solution; using the ToLower() method on the string object and comparing the original string input to the lower version of the same sentence. The code is shown below.

  • Using The ConnectionStringBuilder class

    Building a connection string from scratch can sometimes be a little daunting when you do not know the exact syntax. Of course, you can always visit www.connectionstrings.com and find some great help there. In lieu of this you can also use the ConnectionStringBuilder class. Each of the ADO.NET providers supplies a version of this class that will build a connection string for you. Below is an example of how to use this class.

Past Blog Content

Blog Archive