N
N
NikitaSova2020-07-13 11:41:02
C++ / C#
NikitaSova, 2020-07-13 11:41:02

How to track character positions in a TextBox?

Hi all.
I created 2 textboxes, and I need to make sure that the last time a character is entered in the first textbox, its position in the second textbox is displayed. To solve this problem, I need to understand how to track the position of a character, and I already know how to make an input.
Please explain to a newbie how to do position tracking.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Enerdje, 2020-07-13
@Enerdje

protected void TextBox1_TextChanged(object sender, EventArgs e)
{
  if (!String.IsNullOrEmpty(textBox1.Text))
    textBox2.Text = textBox1.Text.IndexOf(textBox1.Text.Last()).ToString();
}

M
Maxim K, 2020-07-13
@mkvmaks

Take the length of the line -1 - the first textbox, add spaces in the 2nd to the length of the line of the 1st textbox. So it is possible?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question