top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

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

+2 votes
471 views
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
http://stackoverflow.com/questions/3955971/retrieving-an-accurate-string-array-from-a-richtextbox-control/3956097#3956097

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("http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=site:{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: http://www.pingler.com/seo-tools/tools/google-indexed-pages-checker

...