Hello guys,
I am a beginner in C#
I would like to ask you, how to copy some lines from textbox (or rich textbox)
I have all the source , i just now need to find out how to copy lines.
Here is what i need:
I get web source to richTextBox1 and i want to copy from it some lines , OR line which contains the text i search for, for example i search for example i search for a line which contains the name of the file like:
File Name: asdasd.exe
Downloads : xxx
etc.
If you need any more details ask me.
P.S is there a way to copy text directly from webBrowser1 ?
if there is, please tel me.
Thanks

to copy the lines from richtextbox or textbox (with multiline set to true) you can use Lines property:

string[] lines = textBox1.Lines;
            foreach (string line in lines)
            {
                if (line.Contains(""))
                    rtbResults.Text += line;
            }

if you need some more sophisticated checks on lines probably you will have to use regular expressions (Regex class itd.)... for simple checks standard string functions are sufficient...

if it comes for coping the text directly from webBrowser class I can't see any property for that (it does no mean that it does not exist... :) ) but for sure there are properties that takes html code of the currently loaded page... according to what you want to do with the code there are 3 of them:

HtmlDocument docCode = webBrowser1.Document;
            Stream docStream = webBrowser1.DocumentStream;
            string docString = webBrowser1.DocumentText;

thanks i will try :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.