How to strike out the texts in Paragraph? - c#

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;

Related

UWP: difference between RichEditBox and RichTextBlock in displaying some fonts

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.

Scale button to text Xamarin Forms

Is there a way to scale a button to it's text or align the text left?
I have created a static method that allows me to set a generic theme for my buttons. I know you can use LayoutOptions.Start to make the button go to the left of the page.
public static void DefaultButtonTheme(Button button)
{
//previous code
.
.
button.HorizontalOptions = LayoutOptions.Start;
}
However, for text smaller than a certain amount of letters it is center of the button.
See image below.
I have investigated a bit this behaviour and I have found that this error appears on Android but not on UWP. I have also tried to use MinimumWidthRequest="0" without result.
So as Anto Maniscalco said you should create a custom control and then overwrite the Android render using android:minHeight="0dp" as you can see in the following link. It seems that Google decided by default to a minimum size for this control.
I hope this can help you.

XtrReports, xrPictureBox how to align Image to right ? Winform Devexpress

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.

rtf change font size

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.

Change line spacing in winform RichTextBox

I'm using in my winform project a RichTextBox control to display a kind of old console screen.
This works perfectly but there is a space between the lines.
Is it possible to change this space to be 0 or anything near that.
If i paint a line from vetical line from line 1 to line 5 i don't want any spacing between the line.
Hope you can help me.
There's actually a lot that the Windows Forms RichTextBox doesn't expose. If you have the HWND (Handle property) to the control, you can use the SendMessage API to send the EM_SETPARAFORMAT message to play with the formatting.
In particular the PARAFORMAT2 structure does have some line spacing options that may be relevant. You will have to get your hands dirty with interop though.

Categories