Tuesday, July 14, 2009

C# code 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





[code]


rchTextCode = rchTextCode.txt + DateTime.Today;


[/code]





But it only added it at the end of the text





I am sure I am doing something really obviously wrong, any help?

C# code help?
I work with VB but looking at MSDN it seems similar....so try...





rchTextCode.SelectedText = rchTextCode.SelectedText + DateTime.Today;
Reply:use the selectionstart property to determine the


location of the cursor/caret.





richTextBox1.Text=


richTextBox1.Text.Insert


(richTextBox1.SelectionStart , "hello world");


No comments:

Post a Comment