I am trying to perform edit functions in a RichTextBox on a C# (Windows Forms) application.
I would like to be able to select any number of text characters in the script then change targeted font characteristics.
The trouble I have is that each characters font properties may be set to different font. In this case the textbox ignores the event that I request.
How can I solve my problem?
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.
I have a code to change the size:
RichTextBox1.Font.Size == new System.Drawing.Font(RichTextBox1.Font.Name, yoursize)
And if you want to change only the selected text size:
RichTextBox1.SelectionFont.Size == new System.Drawing.Font(RichTextBox1.SelectionFont.Name, yoursize)
Hope it will help.
Related
I have a project in UWP where I need to display the same text in a RichEditBox and in a RichTextBlock.
For some fonts (e.g. Courier), this is pretty ok and no big problems, but for other fonts (like Arial) the difference is pretty substantial.
Please note that I use exactly the same code, the only difference is just the Font.
Please find an MVCE that reproduces the issue here: https://github.com/vfailla/UWPRichEditBox
How can I setup the two elements to display the text in Arial in the very same visual way?
For some fonts (e.g. Courier), this is pretty ok and no big problems, but for other fonts (like Arial) the difference is pretty substantial. Please note that I use exactly the same code, the only difference is just the Font.
First of all, you will need to set the same CharacterSpacing of these two different controls:
m_richEditBox.CharacterSpacing = 100;
m_richTextBlock.CharacterSpacing = 100;
Then, you will need to set the same FontStretch of two controls, but here comes the issue:After a few tests I found textStretch doesn't work for RichEditBox/TextBox. And by default, the text inside look more like FontStretch.Condensed. So as a temporary workaround, you can set your RichTextBlock.FontStretch to FontStretch.Condensed:
m_richTextBlock.FontStretch = FontStretch.Condensed;
I'll consult through internal channel to report this issue, and I'll update this thread once I got any response.
I have a textBox that grows vertically while typing. Unfortunately when I type a long text (for example a 3 line text) some PART of it gets blurry. What's more, when I prevent it from growing vertically and make it grow horizontally it works fine - the text is sharp then.
What I've tried:
UseLayoutRounding = true;
RenderOptions.TextRenderingMode = "ClearType";
Please forget about
TextOptions.TextFormattingMode = "Display"
It has to be "Ideal".
See the screenshots:
Disable SubPixel Rendering and Anti-Aliasing. Try
SetValue(RenderOptions.EdgeModeProperty, EdgeMode.Aliased);
Since you mentioned:
I have a textBox that grows vertically while typing
I assume then that it's a CustomControl derived from TextBox and with a custom rendering to grow vertically instead of using the builtin text wrap ability.
Since I was unable to reproduce your issue with the stock TextBox and the parameters (with Ideal) you mentioned (I've checked from Framework 4.0 to 4.6 on VS 2013), maybe the blur comes from your custom code.
By the way, with not using the builtin wrap?
TextWrapping="Wrap"
Maybe you should include more code and details, like framework version, visual studio version, OS version and so on.
Likewise, specify your version of "Textbox that grows vertically". Something like this ?
Try increasing the font size of the textbox just a tiny amount (use 1/4s if in pixels). Alternatively, try changing the line height slightly in a similar fashion. I think the problem might be down to WPF's interpretation of the sub-pixels and may be rounding off at the wrong place.
Am using Devexpress Winforms 12.2 version. I designed XtraReport with Logo on right side. When image is small automatically it align to left. I need to set pull right. Their is no option to set alignment in property. How to write programmatically code in BeforePrint event of xrPictureBox ?
I tried this one but didn't work xrPictureBox1.Image = ContentAlignment.MiddleRight; showing error cannot implicitly convert type ContentAlignment to Drawing.Image
Thanks in Advance.
You'd better search their support channel, there are several threads on this subject, like XTraReport - XRPictureBox alignment and XRPictureBox - Provide the capability to specify image alignment. From the last one looks like they finally provided out of the box solution XRPictureBox.ImageAlignment Property, but you need to upgrade to v15.1. If you can't, check if some of the suggested workarounds in the links work for you.
I am developing an app for Windows 8.1
The App parses HTML codes, and displays the contents on RichTextBlock.
Anyway, I'm trying to display some texts with 'StrikeThrough' line. like shown below.
I searched through the web, but I just found that there is no native way to do that on WIndows 8.1
I tried the solution on 'StrikeThrough effect on a TextBlock', but I don't think this solution can display some texts which exceed the width of RichTextBlock (I need those texts to be displayed in new line.)
Also, I don't display texts on TextBlock directly,
In my app, texts are displayed like below
RichTextBlock - Paragraph - Run (Texts)
Is there any good solution for this problem?
(The easiest way to display 'Strikeout texts' on RichTextBlock)
Thanks in advance.
Add this to your text
TextBlock1.TextDecorations = TextDecorations.Strikethrough;
With reference to my previous question here: Changing Font Size for ListView Column in C#. I would like to know how to change the height of the column within a listView with OwnerDraw enabled.
I have succeeded in changing the font using the following code.
using (Font headerFont =
new Font("Helvetica", 10, FontStyle.Bold)) //Font size!!!!
{
e.Graphics.DrawString(e.Header.Text, headerFont,
Brushes.Black, e.Bounds, sf);
}
Although I cannot change the size of the column, giving it a cut-off effect. I have been playing around with the Rectangle.Bounds property but this appears to be read only.
Any suggestions?
Thanks
I have decided to take an alternative approach for my application. I chose to remove the header altogether and replace it with labels within a Container Panel.
This was achieved by changing the HeaderStyle property of the listView to "None". The result allowed me to dock the labels to the top of my listView, giving me the larger text I've been after!
Granted this is a little different to the question asked but provides a simple solution to what appears to be a complex problem! Additionally this would make the column headers static so may not be useful for developing applications requiring numerous changes
Thanks for all your help, and let me know if you would like more detail
Euan
You can try Better ListView Express. It allows changing column header height to arbitrary sizes. It is also free and the usage is 99% same as ListView.