Click to See Complete Forum and Search --> : RichTextBox.


caffineplease
July 22nd, 2002, 09:26 AM
Guru's,
Within c#'s RichTextBox, I like to be able to have a function call for the textbox that allows me to place the cursor at x,y position within the RichTextBox so that I can then display some text at that chosen position.

Is there a way in C#'s RichTextBox to do this?

Regards

John

Arild Fines
July 22nd, 2002, 09:33 AM
Not that I know of, no. You could probably fake it, but components like these tend to be more paragraph/line oriented.

caffineplease
July 22nd, 2002, 09:47 AM
Thanx for your prompt reply. If that's the case then, how do I get the cursor from one text box to be displayed in another box, so that I can type text in the 2nd text box? I like this to be done when a user presses a particular key. A bit like transfering the focus from one textbox to another.

Regards

John

sternaphile
July 22nd, 2002, 02:02 PM
On the keypress event, do a RichTextBox.Focus()

caffineplease
July 23rd, 2002, 02:42 AM
I did that but it doesn't work. It does not allow me to enter any text at all, not in box1 or box2.

sternaphile
July 23rd, 2002, 08:27 AM
As an example, here is what I mean & it works...

.
.
.
private System.Windows.Forms.RichTextBox richTextBox1;
private System.Windows.Forms.RichTextBox richTextBox2;
private System.Windows.Forms.Button btnChangeFocus;
.
.
.
bool bFocused = false;
private void btnChangeFocus_Click(object sender, System.EventArgs e)
{
if(!bFocused)
{
richTextBox2.Focus();
bFocused = true;
}
else
{
richTextBox1.Focus();
bFocused = false;
}
}
.
.
.

<I'll attach a screenshot to show you what I have>