How do you find the location of the little blinking cursor where the user can type, column and row? I couldn't find this anywhere.
To position the cursor at the beginning of the contents of a TextBox control, call the Select method and specify the selection start position of 0, and a selection length of 0.
Syntax: // will give the current position of the cursor document. getElementById("id"). selectionStart; // will get the value of the text area let x= $('#text1').
If you mean WinForms, use the SeletionStart
property to access the current position of the carret. Here is code to get the index, current line and current column.
int index = myTextBox.SelectionStart;
int currentLine = myTextBox.GetLineFromCharIndex(index);
int currentColumn = index - myTextBox.GetFirstCharIndexFromLine(currentLine);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With