# Selecting a Paragraph using the Select Method

Learn how to select a paragraph using the Select method available in the C1Editor for WinForms control.

## Content



The [Select](/componentone/api/win/online-richtexteditor/dotnet-framework-api/C1.Win.C1Editor.4.8/C1.Win.C1Editor.C1Editor.Select.html) method in the [C1Editor](/componentone/api/win/online-richtexteditor/dotnet-framework-api/C1.Win.C1Editor.4.8/C1.Win.C1Editor.C1Editor.html) is equivalent to the familiar **Select** method in the **TextBox** and **RichTextBox** controls. You pass the index of the first character in the selection and the selection length, and the current selection is updated.

The code below shows how you could use the Select method to select the sixth paragraph in the current document:

DOC-DETAILS-TAG-OPEN

DOC-SUMMARY-TAG-OPEN

To write code in C#

DOC-SUMMARY-TAG-CLOSE

```csharp
void selectParagraph_Click(object sender, EventArgs e)
{
    // get text (notice new line handling)
    string txt = this.c1Editor1.Text;
    txt = txt.Replace("\r\n", "\n");
    // find 6th paragraph
    int start = IndexOf(txt, '\n', 6) + 1;
    int len = IndexOf(txt, '\n', 7) - start;
    // select the paragraph
    c1Editor1.Select(start, len);
}
```

DOC-DETAILS-TAG-CLOSE

The code starts by retrieving the [Text](/componentone/api/win/online-richtexteditor/dotnet-framework-api/C1.Win.C1Editor.4.8/C1.Win.C1Editor.C1Editor.Text.html) property and replacing _cr/lf_ combinations with simple _lf_ characters. This is necessary to get the selection indices to match the content of the document. Next, the code uses the **IndexOf** helper method to find the position of the sixth paragraph. Finally, it selects the paragraph using the Select method.

The implementation of the **IndexOf** method is as follows:

DOC-DETAILS-TAG-OPEN

DOC-SUMMARY-TAG-OPEN

To write code in C#

DOC-SUMMARY-TAG-CLOSE

```csharp
int IndexOf(string text, char chr, int count)
{
    for (int index = 0; index < text.Length; index++)
    {
        if (text[index] == chr)
        {
            count--;
            if (count <= 0)
            {
                return index;
            }
        }
    }
    return text.Length;
}
```

DOC-DETAILS-TAG-CLOSE