[Solved] How to access RichTextBox.Select() method while referring to it as a “Control”


private void TextSelectionAtSomePoint() {
    int selectionStart = 0;
    int selectionEnd = 6;
    var temp = tbcPages.Controls[0].Controls[0] as RichTextBox;
    if(temp != null)
        temp.Select(selectionStart,selectionEnd);
}

UPDATE:

As @JonSkeet said in comments, seems the OP expects a RichTextBox here; so if it’s not, it really should throw an InvalidCastException, not just ignore it. So, I update the answer to this:

private void TextSelectionAtSomePoint() {
    int selectionStart = 0;
    int selectionEnd = 6;
    ((RichTextBox)tbcPages.Controls[0].Controls[0])
        .Select(selectionStart,selectionEnd);
}

6

solved How to access RichTextBox.Select() method while referring to it as a “Control”