using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using System.Threading;
namespace ChangeTextCase
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnCopy_Click(object sender, EventArgs e)
{
txtDestination.SelectAll();
txtDestination.Copy();
}
private void btnChangeCase_Click(object sender, EventArgs e)
{
string sText = txtSource.Text;
txtSource.Text = "";
txtDestination.Text = "";
#region Get the culture property of the thread.
CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
//Create TextInfo object.
TextInfo textInfo = cultureInfo.TextInfo;
#endregion Get the culture property of the thread.
#region Title case
if (rbTitleCase.Checked == true)
{
sText = sText.ToLower();
txtDestination.Text = textInfo.ToTitleCase(sText);
}
#endregion Title case
#region Lower case
if (rbLowerCase.Checked == true)
{
txtDestination.Text = sText.ToLower();
}
#endregion Lower case
#region Upper case
if (rbUpperCase.Checked == true)
{
txtDestination.Text = sText.ToUpper();
}
#endregion Upper case
#region Remove Line Break - Start
if (rbRemoveLineBreak.Checked == true)
{
if (ckRemoveTabs.Checked == false)
{
//txtDestination.Text = sText.Replace(System.Environment.NewLine, sText);
string replaceWith = "";
txtDestination.Text = sText.Replace("rn", replaceWith).Replace("n", replaceWith).Replace("r", replaceWith);
}
else
{
//txtDestination.Text = sText.Replace(System.Environment.NewLine, sText);
string replaceWith = "";
txtDestination.Text = sText.Replace("rn", replaceWith).Replace("n", replaceWith).Replace("r", replaceWith).Replace("t", replaceWith).Replace(" '", "'");
}
}
#endregion Remove Line Break - Stop
}
}
}
Originally Posted on February 22, 2013
Last Updated on February 8, 2016
Last Updated on February 8, 2016
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

You must be logged in to post a comment.