How to stop Windows Forms label text from rearranging itself - winforms

Today I tried using Windows Forms for the first time, which went pretty smoothly until I tried setting the text of a label to "0 lines", which was displayed as "lines 0" in the actual program. I tried a couple of other inputs for the Text property, and it seems the leading number in the label is always moved to the back. I couldn't find any property in the label describing some sort of numerical formatting, so I was wondering were this rearranging came from and what I could do to disable it. Thanks in advance!
screenshot of the input
screenshot of the result

As CodeCaster said in their comment, I simply had to change the RightToLeft property.

Related

Crystal Reports is cutting right text on report and paper

I got this problem that drive me crazy. I have a project in VS2013 with v.13.0.15.1840. I'm using a auto grow field (has his own section) in crystal reports that is displaying a text interpreted as RTF. The problem is that on preview and even paper, the right side of the text is cut off (see screenshot). If the text is justified the it shows OK but I have situations when I need the text align to left.
So far I tried but with no effect:
Setting margins manually on Format Object, Paragraph.
Selecting no printer,Disassociating formatting page size and printer paper size.
Making the field smaller horizontally.
Does anyone know a solution for this?
The field on designer:
Edited for further explanations:
The RTF code can be viewed at https://gist.github.com/andySF/7ca61ffbe6ab6da53ca1
Also another try was to put my field in a textbox and then setting the right margin of the textbox to 3cm. It appears that the margin is somehow overridden after the first paragraph.
Use
Modyfi your datasource text rtf before send in to report CR
model.Document= model.Document.Replace("\pard", "\pard\ri380")

ToolTip works very slow for long text (2000+ chars)

We need to use the built-in WinForms tooltip control to display a very long tooltip (about 4000 characters) for one of our controls. But if we do so, the form freezes for a minute or two when we place the mouse pointer into the target control to see the tip. And nothing happens after that.
We experimented and detected that the standard tooltip starts to work very slow when it has about 2000 chars, and the situation becomes much worse when we increase the number of chars. Is it a known issue, and is there any workaround for it? Please, don't suggest to trim the tip text - we need to display the string as is.
When you assign a string of text to a ToolTip, part of the process of drawing it involves calls to USP10.dll which handles Unicode layout of characters on screen. I was able to see this by looking at the stack trace while the program was freezing. The performance of this layout is terrible for long strings.
Disabling Visual Styles for the application (commenting out EnableVisualStyles()) fixed the problem - the tooltip displays immediately, though this is not an optimal solution.
I kept looking and found this page which indicates the problem may be linked to layout of long strings where word-wrap is necessary. By inserting line breaks into the tooltip text, I found that the string displayed immediately. So, if you can determine where to insert the line breaks manually, the ToolTip should display quickly.
What about using another Tooltip , i.e. HtmlToolip?

wpf Richtextbox selected text distorted

I am experimenting with the WPF RichTextBox and it shows some text in my application. I notice that When I select some text in that RichTextBox, the selected text gets distorted and the text below to that also gets distorted as shown below.
After I deselect that and scroll it comes back to normal.Is there anyway to avoid this distortion?
Now I solved this problem by myself. I just added the following single line of code in my application and make it works. We need to disable hardware acceleration in screen settings using this.
RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.SoftwareOnly;
This helped me a lot to fix my issue and it works for me.

RichTextBox SelectionFont is unexpectedly *not* null

I'd like to change the font size of a chunk of RTF without erasing the bold / italic / underline formatting (an issue similar to the one in this question). The accepted answer is to modify the selection of the text box until the SelectionFont propery is null in order to find runs of consistently formatted text which can be modified individually. Sounds reasonable. However the actual behavior of the RichTextBox control seems to be inconsistent with the documentation.
In the documentation for RichTextBox.SelectionFont MSDN states:
If the current text selection has more than one font specified, this
property is null.
However, this code which uses mixed bold / regular text doesn't behave as you'd expect:
var rtb = new RichTextBox {
Rtf = #"{\rtf1 This is \b bold\b0.}"
};
rtb.SelectAll();
// Now you'd expect rtb.SelectionFont to be null,
// but it actually returns a Font object
Is there any other reliable way of formatting the text so that I can change the font size without clobbering the other formatting. (Manipulating the RTF directly is OK, I'm not absolutely set on using WinForms to achieve this).
I've given up on trying to go through Winforms to fix this. As I'm applying the change to a whole document (rather than just one portion), it turns out that it's not too hard to modify the RTF directly.
In this case I'm interested in the font size, which is represented by the \fs command. So to replace all the 8.5pt text with 10pt text, you can replace \fs17 with \fs20. (Yes, RTF font sizes come in units of half a point, apparently).
This seems to work well enough, although it does feel like one of those "let's mangle our HTML using regular expressions" type solutions, so I'm not convinced that it's very robust.
Take a look at this:
Changing font for richtextbox without losing formatting
I think it's the same issue. LarsTech's solution is working perfectly for me.

Silverlight 3 - Control over wrapping in TextBox

Ok I have the following problem in Silverlight. I have a control with 2 columns. On the left is a stack panel with line numbers and on the right is a textBox.
So when I write in textBox without wrapping turned on I can simply create the right count of numbers on the left, because I'm searching for '\r' in text.
But when I turn on wrapping I have no control over the count of lines in textBox.
Is there a way to get to that count? Or a way to know which line in textBox is going to wrap?
I hope you can understand what I'm trying to do.
There's one way to do this. You can simulate the word wrap operation in the background using a TextBlock. Here is a good link of the complete solution to this problem.
Extended TextBox control with MaxLines property
Is it not possible to create your items in code before they are passed to the view. This would enable you to bind a list of items to a listview and style them as you wish.
You need to user a value converter to count the number of char / lines and then trim that number if you wish to. Unless you use fixed width, you can't really count or calculte in advancet the size, since each application might be displayed differently (due to different sizing option).
There are two great sample chapters on Windows Phone and Silverlight for Windows Phone on the LearningWindosPhone.com site. There is great Windows Phone Trainng material , and dont forget the Windows Phone Develoeprs Blog
Yes there is a way to get the number of lines occupied by the text in the textbox. It's not that simple though 'coz you have to simulate the behavior of the word wrap in order to count/predict the number of lines generated as a result of a word wrap. I have the solution described here in detail.

Resources