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.
Related
I have a C# program that uses an Infragistics UltraWinGrid to display comments. A comment can be multiple lines. That is, it can contain carriage return/line feeds (CRLFs). (See the upper portion of the attached screenshot.) But when the user selects the text of the comment by clicking on the cell, it loses the CRLFs. (See lower portion.) This is a problem, because comments can be very long and the user may want to copy and paste a comment somewhere else without losing the formatting.
From what I understand, this problem results because the grid uses a Windows textbox as an editor when the user clicks on a cell. Is there some way that I can either make the textbox keep the CLRFs or replace the textbox with an editor that does? Thanks.
Turns out there are a few stars that need to align for this.
Of course CellMultiLine needs to be set for the column like wnvko pointed out.
But also, you must make sure your Column Style is NOT FormattedText or FormattedTextEdit. (If that's required for editing i think you are out of luck). Just use Default style.
And finally make sure you CRLFs are actually truly CRLFs. My best suggestion is to use Environment.NewLine. If you are pulling the data from the DB, make sure you use CHAR(13) + CHAR(10) in that specific order. See Differences Between vbLf, vbCrLf & vbCr Constants
Hope this helps 4 years later. :-) But wanted to share for others since i found no solution elsewhere.
My suggestion is to use Templates. Have a look at the official Infragistics UltraWebGrid help book that is explaining in depth how to configure features like Row and Column Templates.
Go to page 74 for more information regarding the templating.
You should set CellMultiLine of the column to True. Here is how it is working when I set it in my grid
I never found a real answer to this question, but I was able to do a workaround by capturing the click event and having it open a small dialog box containing the cell text. I had the dialog box open at the point the user clicked, so that it appeared over the cell. After a few minor adjustments to take care of border conditions, it worked surprisingly well, so I'm calling this one solved. Thanks, everyone, for your suggestions.
I believe am in need of creating custom RichTextBox in C#. One kind of like that:
I admit it might not even have to be RichTextBox, but after some research I decided it's gonna be the easiest way. Functionality I need are icons at each row, checkboxes and text formatting. My program will process each line of the text and mark lines that are correct, incorrect, and strike out lines not necessary in further work, while showing line that's currently processed and allowing user to edit some lines freely (here: lines before Around 3 000 won't be editable, but those under the line will).
What's the problem then? I have no idea how to get it done. I've seen tutorial on how to make single-line textBox with icon or checkbox nearby, but I have no idea how to make both, and for multiline textBox (so I could freely scroll and everything would work fluently). I've read some questions on SO as well, but neither helped me.
I just don't know how to get started, I realize it won't be 5 min work, but I'm willing to do it. Until now I've been only able to create custom control deriving from RichTextBox, but I have no idea which methods and how to override. Any help appreciated.
Try to use WebBrowser control instead RichTextBox.
You can add CheckBoxes and editable content by setting a correct HTML code to it.
Set each TextBox or CheckBoxes ids and use GetElementsByTagName or GetElementById to access inner elements to get or set its attributes or values.
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.
Is there a way to prevent the MessageBox from breaking a string instead of just growing to the width of the string? I'm porting an old VB application and they use message boxes to present a sizable amount of data to the user. I suppose I could create a form, but I've already started down this road, and would not like to have to go back.
Thanks.
The only (supported) way to have such control over how things get laid out here is to ditch the MessageBox helper class and build a custom Form class that does what you need.
We have dealt with this issue in the past be embedding newlines (\r\n) in the text of our message. MessageBox will grow vertically to honor the wrapping text. We used to have MessageBoxs so wide you couldn't even see the centered buttons, but now they show up fine.
Depending on the complexity of generating the message text and/or whether you have control over that, this may be your simplest solution. Otherwise, I think you will need to create your own form.
For example:
MessageBox.Show("Line1\r\nLine2\r\nLine3\r\nLine4", "MessageBox test");
MessageBox.Show("Line1 Line2 Line3 Line4", "MessageBox test");
The first line creates a MessageBox with 4 lines of text and the window has grown to the correct height to show all. The second line creates a MessageBox with a single line and the appropriate width to show the whole line.
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).