Friday, April 23, 2010

How to get string in Title case

Here is the code example for converting the string to title case
DateTime todaysDate = DateTime.Now;
CultureInfo properCase = System.Threading.Thread.CurrentThread.CurrentCulture;
TextInfo textInfoObject = properCase.TextInfo;
grp.DrawString(textInfoObject.ToTitleCase(todaysDate.ToString("MMMM")) + " " + todaysDate.Year, new Font(new FontFamily("verdana"), 12, FontStyle.Bold), new SolidBrush(textColor), new PointF(360, 230));