CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: RichTextBox.

  1. #1
    Join Date
    Jul 2000
    Location
    In a flat, Wimbledon, UK
    Posts
    251

    Question RichTextBox.

    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

  2. #2
    Join Date
    Oct 2001
    Location
    Norway
    Posts
    265
    Not that I know of, no. You could probably fake it, but components like these tend to be more paragraph/line oriented.

  3. #3
    Join Date
    Jul 2000
    Location
    In a flat, Wimbledon, UK
    Posts
    251

    RichTextBox

    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

  4. #4
    Join Date
    Apr 2001
    Location
    Midwest
    Posts
    57
    On the keypress event, do a RichTextBox.Focus()
    "Judge a man by his questions rather than his answers." - Voltaire

  5. #5
    Join Date
    Jul 2000
    Location
    In a flat, Wimbledon, UK
    Posts
    251
    I did that but it doesn't work. It does not allow me to enter any text at all, not in box1 or box2.
    Last edited by caffineplease; July 23rd, 2002 at 02:44 AM.

  6. #6
    Join Date
    Apr 2001
    Location
    Midwest
    Posts
    57
    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>
    Attached Files Attached Files
    "Judge a man by his questions rather than his answers." - Voltaire

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured