This worked for me:
public void splitString(string[] strText)
{
string[] arr = txtEntryField.Lines;
for (int n = 0; n < arr.Length; n++)
{
if (arr[n].Length > 8)
{
arr[n] = arr[n].Substring(0, 8);
}
}
txtEntryField.Lines = arr;
if (txtEntryField.Lines.Length > 0)
{
txtEntryField.SelectionStart = txtEntryField.Text.Length;
}
}
Also the below code allows the user only to enter the desired characters:
void txtEntryField1_KeyPress(object sender, KeyPressEventArgs e)
{
const char Delete = (char)8;
var regex = new Regex(@"[^.,0-9\s]");
if (regex.IsMatch(e.KeyChar.ToString()) && e.KeyChar != Delete && e.KeyChar != (char)Keys.Enter && e.KeyChar != (char)Keys.Back)
{
e.Handled = true;
}
}