Format RTF text into multiple textboxes - c#

I have a richtextbox on my wpf form that the user types into, with no restrictions on length. However, on my active reports output, I have pages with fixed-space textboxes on each page. Is there any way to figure out how much of the rich text will fit into a textbox, write it out, and then continue writing the rest on the next page until i run out of text to write?

You can measure the length of plain text on an ActiveReports Page using the Page object's MeasureText method. See the following documentation: http://www.datadynamics.com/help/activereports6/ActiveReports.Document~DataDynamics.ActiveReports.Document.Page~MeasureText.html
If you have RTF output (I'm not sure if you do or not based on the information provided) it is probably not feasible to manually measure the text and break it up simply because RTF text is complex and breaking into parts is more difficult. However, the RichEdit/RTF control in ActiveReports should be able to paginate/page break it fine if you can let that control grow.

Related

Form with pleny of textboxes and Formatted text crashes [C#]

I am developing an application that requires to load lots of textboxes dynamically. It may vary according to certain conditions. And each one of these textboxes' text is formatted differently: Some of them will have their text in Bold, some of them underlined, and so on. Kind of like a document.
All of these textboxes are included in a flowlayoutpanel, and this flowlayoutpanel's flow is up to down and autoscrollable. So when i scroll down the "document", everything goes blank for some reason, there are white lines and rectangles all over the textboxes and then, the application crashes.
Screenshot of the problem.
Sometimes it might throw a Generic GDI+ error exception, some others an Out of Memory exception. So I decided to try out putting all of these textboxes without the format (just the text with no bold/italic/underlined styling), and it works just fine like that.
My question is: Is there a way to prevent these type of errors without having to remove the format from the text? If not, could there be another approach to this?
I'd highly appreciate good feedback on this one.
Thanks in advance.

UP simple Way to store/retrieve formatted Text

currently, I'm using Richeditbox in my to edit and display formatted text in App. there a now a lot of RichEditBoxes. because its the goal of the App, to show a list of formatted text blocks with different Content. The Performance is really slow and the space in DB is great, I'm storing the text in RTF-format in blobs.
What is the easiest way to show simple formatted Text (eg bold, italic)? I never found a quite sample?
If you just want to display formatted text you have two options.
RichTextBlock is a TextBlock-like counterpart of RichEditBox. It is however more performant as it just displays the content and does not offer editing.
Alternatively there is a MarkdownTextBlock control in the UWP Community Toolkit, which can display simple formatted text in the Markdown format.

Is it possible to have differently colored lines in multiline text box?

Is it possible to have differently colored lines in multiline text box?
I'm adding data to the text box and I want to clarify for the user different types of text by color.
How to do this if it's possible?
You can do this if you use a RichTextBox control. See the documentation here (particularly look at the Remarks and Examples sections). The standard TextBox does not offer this capability.
The standard Winforms textbox does not have this ability (and adding it would be troublesome).
You could look at using the System.Windows.Forms.RichTextBox as an alternative for this or one of the many commercial alternatives.
So depending on how you want the output, there's an browser/html control (basically a box), that you can pass a URL or a string of HTML, depending on what you're doing, you might want to use the RickTextBox - which has formatting commands - you could use regular expressions, or the offset of the text and then use a "set color" command on the text box with an IF structure.

RichText box has not displaying the large text in WPF with MVVM

How to display the large text in the richtextbox. I need to use with MVVM pattern.
Can anyone suggest me a wpf control to display large text or how to make the richtextbox to display entire content?
Richtextbox can display more than 1000 lines. I use the one for cat and it works just nice(with all the formatting and etc). May be you have vertical scroll OFF and you cant see the rest of the lines?! see Shoaib Shaikh answer with suggested properties values.
Rich text box can also have same properties to accept multiple lines as textbox does. in order to conditionally format some lines in red you will have to provide Flow document in RichTextbox. you can create flow document by xml. this is an article could be helpful
http://www.codeproject.com/KB/WPF/BindableWPFRichTextBox.aspx

C# Correct way to design/implement this UI?

This is my first tryst with C#. The form that i have in mind consists
A textfield which will be supplied with the path of an executable.
A "Run" button which will call the executable(cosole app)
The executable console output should be displayed in the rich textbox.
Now when i click on a line in richtext box, i select and get the text in the line. This text maps to some other text info. I need to display this text info as a tooltip over the line.
More explanation:
The output of the exe is displayed in the text box as
Address1=Value
Address2=Value
Now when i click the line "Address1=Value", i map this text to find some info regarding what bits are set like
enable : 1
select : 0 ..etc
this info i need to display as tooltip over the line. Is such a thing possible? Is there better alternative to RTB/tooltip for this problem?
Thanks
Vivek
I would recommend using a ListBox for each string of data returned and then if you use a tooltip it makes alot more sense because you are hovering over a list item specifically not the whole text field.
Using the ListBox and items should make it alot easier to work with overall since it will be separating them into defined items instead of just appending lines to a text box.
Also I think you might have alot of work in store for you for trying to make the text box behave the way you want it to for it to treat each line differently dependent on the text of the line.
If you're using the textbox because later you want to be able to select all the output to copy and paste it I would have the textbox hidden by default and have a button that says like "Toggle Raw Output" that will show/hide the text field so users can get the text easily. While using the ListBox as the primary display for information.
What I understand from your question is that when you click on the line in the RTB, your code scans the text on that line, identifies the extra data associated with that line and then inserts it into the tooltip for the RTB.
Technically I believe that this is possible to do - although I am not 100% sure of the mechanics of inserting tooltip text. However as a user interface feature I would personally not do that as the tooltip text is displayed whenever the mouse pointer is anywhere over the RTB. Thus if a user clicks on line #1, (and sees the data associated from line #1) but hovers the mouse of line #3, they might think that the tooltip is associated with line #3.
You could alleviate my concerns with a strongly worded tooltip, but I feel that what you are doing is misusing the tooltip for something other than what it was intended to be used for. IMHO it may be that you are better off displaying your data with a tree control rather than with a RTB, as the tree control more naturally expresses the functionality that you desire (click on a node, expand it to see details etc).

Categories

Resources