Question: I am working on WPF MvvmLight application and once I click on first page it navigates to second page. The second page has a textbox on which the focus is set. On this textbox, I am not able to put any data or any character. But I can do copy and paste. What might be the reason for this strange behavior. 

```
<TextBox VerticalAlignment="Center" x:Name="txtsearchYouTube" Height="25"
    Margin="100,0,100,0" Canvas.Top="275" Width="500"
    Loaded="txtsearchYouTube_Loaded" Canvas.Left="50"
    Text="{Binding SeachKeyWord,Mode=TwoWay,
    UpdateSourceTrigger=PropertyChanged}"/>

```

Answer: 
Firstly, your code creates a new cursor at the beginning of the document each time you press the next button, so you will always search from the beginning. Secondly, you must understand that the cursor you manipulate has nothing to do with the one in your `QPlainTextEdit`: you manipulate a copy. If you want to impact the text edit, you must modify its cursor using [`setTextCursor`](http://doc.qt.nokia.com/main-snapshot/qplaintextedit.html#setTextCursor). Here is a working solution:

```
void TextEditor::findNextInstanceOfSearchTerm()
{
    QString searchTerm = this->edtFind->text();

    if(this->TextDocument == NULL)
    {
        this->TextDocument = ui->Editor->document();
    }

    // get the current cursor
    QTextCursor documentCursor = ui->Editor->textCursor();

    documentCursor = this->TextDocument->find(searchTerm,documentCursor);

    if(!documentCursor.isNull())
    {
        // needed only if you want the entire word to be selected
        documentCursor.select(QTextCursor::WordUnderCursor);

        // modify the text edit cursor
        ui->Editor->setTextCursor(documentCursor);
    }
    else
    {
        ui->statusbar->showMessage(
            "\""+searchTerm+"\" could not be found",MESSAGE_DURATION);
    }
}

```

As a side note, you might want to know that `QPlainTextEdit` provides a [`find`](http://doc.qt.nokia.com/main-snapshot/qplaintextedit.html#find) method, so this might be an easier way to achieve what you want:

```
void TextEditor::findNextInstanceOfSearchTerm()
{
    QString searchTerm = this->edtFind->text();

    bool found = ui->Editor->find(searchTerm);

    if (found)
    {
        QTextCursor cursor = ui->Editor->textCursor();
        cursor.select(QTextCursor::WordUnderCursor);
        ui->Editor->setTextCursor(cursor);
    }
    else
    {
        // set message in status bar
    }
}

```
1. Use `QTextCursor::EndOfWord`
2. Use `QPlainTextEdit::setExtraSelections` to select/highlight something in QPlainTextEdit

Simply you already have cursor that would highlight word, but you didn't apply it to text edit