Inserting text at the current location in a text box
-
Hello. I am trying to get a program to insert the date at where current text is being typed (not explained very well, I mean the little line when you type name is on the tip of my tongue...). At first I tried to get it to appear using the following code
rchTextCode = rchTextCode.txt + DateTime.Today;
But it only added it at the end of the text I am sure I am doing something really obviously wrong, any help? < -
Hello. I am trying to get a program to insert the date at where current text is being typed (not explained very well, I mean the little line when you type name is on the tip of my tongue...). At first I tried to get it to appear using the following code
rchTextCode = rchTextCode.txt + DateTime.Today;
But it only added it at the end of the text I am sure I am doing something really obviously wrong, any help? <Try the following:
textBox1.Text = textBox1.Text.Insert(textBox1.SelectionStart, DateTime.Today.ToString());
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook