getting text from a RichTextBox

Class library usage, coding and language questions.
oroosen
Posts: 3
Joined: Fri Jul 27, 2012 7:25 am

getting text from a RichTextBox

Post by oroosen » Tue Sep 04, 2012 12:27 pm

Hello,

The software that I'm testing has a log window with a text field (System.Windows.Forms.RichTextBox) and I want to extract it and save it together with the test report.

When I use the following code, it only adds 4k of text, not the entire text field.
TextWriter tw = File.CreateText( pathToLogFile );
tw.Write( repo.MachineConfigurator.LoggingOutput.Text.SelectionText  );
tw.close();
How can I get the remaining part of the text?

Kind regards,
Okke

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3949
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: getting text from a RichTextBox

Post by odklizec » Tue Sep 04, 2012 1:36 pm

Hi,

My guess is that the text is not entirely visible (lazy loaded) in the RichTextBox and this is why you are not getting the whole text. I think your only hope is to scroll the text in the RichTextBox (using PageDown or just Down key) and read and merge each loaded page with the previous one. Do it in a loop using the RichTextBox scroll bar max/page value (if available). This should help you with "loading" entire text.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration