In c# textbox when enter key is pressed, how do you the index where it was pressed?
For example, I have a textbox named txtDesc and txtDesc currently contains the phrase
“The quick brown fox jumped over the lazy dog.”
My cursor position is after the word “fox” and then I pressed the enter key…
How do I know which index position I pressed the enter key?
private void txtDesc_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
//enter key is down
//How do I know which index position I pressed the enter key?
}
}
I should be able to get the index 19 since that’s the position after the “fox”.
I want that position so I can manually place html code “<br>” after the word “fox”. Which is where I pressed the enter key…