top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

how to get all the text from a richtextbox into an array?

+2 votes
how to get all the text from a richtextbox into an array?
posted Oct 7, 2014 by Brajaraj Jena

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Check this link

The catch is u need to get the firstLine and lstLine

int firstLine = richTextBox1.GetLineFromCharIndex(0); 
int lastLine = richTextBox1.GetLineFromCharIndex(richTextBox1.Text.Length);

and then run a loop something like

    List<string> lines = new List<string>();
    for (int i = firstLine; i <= lastLine; i++)
        int firstIndexFromLine = richTextBox1.GetFirstCharIndexFromLine(i);
        int firstIndexFromNextLine = richTextBox1.GetFirstCharIndexFromLine(i + 1);

        if (firstIndexFromNextLine == -1)
            // Get character index of last character in this line:
            Point pt = new Point(richTextBox1.ClientRectangle.Width, richTextBox1.GetPositionFromCharIndex(firstIndexFromLine).Y);
            firstIndexFromNextLine = richTextBox1.GetCharIndexFromPosition(pt);
            firstIndexFromNextLine += 1;

        lines.Add(richTextBox1.Text.Substring(firstIndexFromLine, firstIndexFromNextLine - firstIndexFromLine));

Hope this will help.

answer Oct 8, 2014 by Salil Agrawal
Similar Questions
+3 votes

I want get Number of indexed pages of any website so, it will give me exact number of pages in google.
What I have tried:

Uri queryUri = new Uri(string.Format("{0}", url));
using (WebClient client = new WebClient())
    string getString = client.DownloadString(queryUri);
    dynamic s = JsonConvert.DeserializeObject(getString);
    var IndexedPage = s["responseData"]["cursor"]["estimatedResultCount"].Value;
    lblIndexedPageRecv.Text = IndexedPage;

its working but not giving me right answer

my code is giving different values then other online webCheckers like one of this:

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.