When displaying a Form as a Dialog/Modal Box sometimes you may need to avoid the Dialog form to close.
Let’s say we have a main form that displays another form as a Modal dialog to finally display some information from that form.
Continue reading…
C#
When displaying a Form as a Dialog/Modal Box sometimes you may need to avoid the Dialog form to close.
Let’s say we have a main form that displays another form as a Modal dialog to finally display some information from that form.
I was working on an application when suddenly I stepped into a method that intrigued me.
public static string NameFormatter(string name)
{
    if (!String.IsNullOrEmpty(name))
    {
        int index = 1;
        char[] separator = new[] { ' ', '-', '_', '.', '\'' };
        name = name.Substring(0, 1).ToUpper() + name.Substring(1);
        while ((index = name.IndexOfAny(separator, index)) > 0)
        {
            index++;
            if (name.Length > index + 1)
            {
                name = name.Replace(
                                name.Substring(index, 1),
                                name.Substring(index, 1).ToUpper());
            }
        }
    }
    return name;
}