I am trying to be able to paste (mouse or keyboard shortcut) a 12 digit number (IP address, but no periods between) into 4 fields. Each has maximum length of 3.
I am trying to do this by using TextChange, text box, property. I was trying to use Substring but it doesn't each octet work.
public PingIPRange()
{
InitializeComponent();
txtF1.TextChanged += new EventHandler(NextField);
txtF2.TextChanged += new EventHandler(NextField);
txtF3.TextChanged += new EventHandler(NextField);
}
private void NextField(object sender, EventArgs e)
{
if (txtF1.TextLength == 3)
{
txtF2.Focus();
txtF1.Text = txtF1.Text.Substring(0, 3);
txtF2.Text = txtF1.Text.Substring(3, 30);
}
if (txtF2.TextLength == 3)
{
txtF3.Text = txtF2.Text.Substring(3, 27);
txtF3.Focus();
}
if (txtF3.TextLength == 3)
{
txtF4.Focus();
}
}