Silverlight 4 RichtTextBox - how do I get the text without the formatting? - silverlight-4.0

How do I get the text out of a Silverlight 4 RichTextBox without the formatting? I know the Xaml property will give me the XAML but I just want the text.

This is a little late, but I will post anyway. There is a trick that involves selecting all the text in code and then accessing the Text propety of the TextSelection object. Like so:
myRichTextBox.SelectAll();
var plainText = myRichTextBox.Selection.Text;
I am using it in my apps and although it is not the prettiest solution, it works. Found it here:
http://forums.silverlight.net/forums/p/184560/422007.aspx

If you just want text, why not use TextBox instead?

There are various third-party components that support this kind of functionality (unfortunately paid). For example, Telerik's RadRichTextBox supports both highlighting and exporting rich text content as plain text, latter trough component called TxtFormatProvider.

Related

How to create a Tokenizing Control for UWP as known from Outlook when using To, Cc and Bcc

There is a great article about how to write a Tokenizing Control for WPF here: Tokenizing control – convert text to tokens
But how is this accomplished in an UWP App? The Windows 10 UWP Mail client does this just fine, so I know that it is possible. But how?
Tokenizing is super useful for To/CC/BCC input areas, as we know it from Outlook and lately from the Windows 10 UWP Mail client.
I suspect that RichTextBlock or maybe RichEditBox combined with AutoSuggestBox could be part of the answer, but in the WPF example above FlowDocument is used and FlowDocumet is not supported in UWP.
I haven't looked at their code. They likely have a text input control of their own, but you could achieve a fairly similar and possibly acceptable effect by putting (Rich)TextBox and "token" elements in a WrapPanel. You won't be able to easily select all text, but you could get clickable token elements.
Otherwise - you might have a bit of work figuring out completely hand-crafted input and rendering.

Check if RichTextBox has formatting (vb.net)

Is there a way to detect if there is formatting or not (i.e. Rich) anywhere in a RichTextBox?
I'd like to write RichTextBox.Rtf is there is, and RichTextBox.Text if there isn't.
I came across a post that suggested checking the SelectionFont after selecting all text, but I have no idea how to accomplish that, or if it would work.
Thanks!
You can check the rtf property of the richtextbox: richtextbox1.rtfto see the rich text code. Even with no additional formatting, there will be some rich text formatting. For example, here's what you get with a richtextbox containing only "text":
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}
\viewkind4\uc1\pard\f0\fs16 test\par
}
You can check to see if there are any additional formatting tags, and if not, it should be plain text. You can also access the plain text (without formatting) with richtextbox1.text.

Curve Texblock in XAML / W8.1 throughTemplate?

Is it possible to access the TextBlock Template to change the border and make it curved?
I tried editing the Template through Blend but with no success.
I'm trying to achieve something like this (couldn't get that given solution working):
Curve TextBlock in Windows 8
I'm trying to do this in C#/XAML - WINRT (Windows 8.1)
I don't think a TextBlock has a template you could modify. It's probably just some parameters used to tell DirectWrite what text to render and with what properties. The easiest way to solve it is when your text is constant to just break it apart into multiple single letter TextBlocks and lay them out on a path using Blend or Illustrator. If don't control what text can show up on the path - you'd have to code up the layout algorithm. Chris's link seems like a good place to start.
There isn't a clean way to do this directly in Xaml. Like Filip says, you can approach it by breaking the letters apart. That can work well for long sentences with small letters, but can be pretty chunky with large or connected letters. If you need smoother rendering then you can interop to Direct2D.
MSDN has a Direct2D animated text on a path sample which you could combine with the XAML SurfaceImageSource DirectX interop sample

Understanding RTF and edit it with vb.net

I have this RichTextbox in my vb.net form and I would like to when a user click a button, for example to embold the selected text, how would I do this.
Also, I do NOT want to use the standard vb.net expressions such as RichTextBox1.SelectedText.Font.Bold = True. I want to do something like RichTextbox1.SelectedRTF="[bold]" & RichTextBox1.SelectedRTF & "[/bold]" or whatever RTF looks like.
Can I just add the RTF options random places or can a RichTextBox return an error if the text is in wrong format. I'm mostly looking for info on how to work with RTF without using the standard vb expressions. Thank you very much for any help provided
It just doesn't work this way, it is not an HTML editor. Hacking RTF directly is technically possible through the Rtf property but very hard to get right. RTF is not exactly a friendly format. Start reading here, try not to panic at the quality of that first page. Well, go ahead.

itextsharp: how to move the datatable?

as you can see my data table is a little too much on the right, how do i move it more to the left? please include answer in vb.net
alt text http://img38.imageshack.us/img38/3661/fullscreencapture121520.png
If you're using a PdfPTable you can explicitly set the position of the table using the table's WriteSelectedRows() method.
Here's a C# example
Documentation on WriteSelectedRows (such as it exists) can be found at the sourceforge tutorial.
The links I provided are in C#. I've seen very little iTextSharp code in VB.NET but ran this class through the DeveloperFusion C# to VB.NET converter and results looked good to me. If you haven't already, you might want to bookmark the DeveloperFusion converter site.
You probably just need to adjust the margins. i'm guessing you're looking at the default.
Here's a simple iTextSharp example that shows how to manipulate margins.