richtextbox

User selecting text in RichTextBox on Windows Phone 8

会有一股神秘感。 提交于 2019-12-01 21:30:29
I am trying to use a RichTextBox in my Windows Phone 8 application. The user needs to be able to select text and copy it to the clipboard. The user DOES NOT need to edit the text, only select it. However, I cannot seem to select text in either the Windows Phone Emulator, or on my Windows Phone 8 device (Nokia 920). The documentation for the RichTextBox.Selection property contains example code for how to change the format of the selected text (bold, italic, etc.). I would assume that the user would have to select text before he can make it bold or italic, but I cannot make it work. The

WPF Richtextbox Application.Find Text spanning Multiple runs

两盒软妹~` 提交于 2019-12-01 20:59:04
I'm trying to implement the Application.Find command for the WPF richtextbox. Let's say I'm searching for "expert". Sounds easy enough. But due to the nature of wpf, if every other letter in "expert" is bolded, then the richtextbox contains e* x *p* e *r* t * and that means six runs exist. I have a starting textPointer. What I'm trying to figure out is how to get the ending textPointer so that I can create a TextRange that I can use to create the Selection. In this example, the starting textpointer is in the first run, and the ending textpointer should be in the last run. Is there a simple way

C# RichTextBox Select specified Text

核能气质少年 提交于 2019-12-01 20:06:00
问题 I have a RichTextBox with -by example- this text: "This is my Text" Now I want to "search" the RichTextBox for a Text (String), by example: "Text" Now "Text" should be selected/highlighted (for each one) in the RichTextBox.. There is something like: myRichTextBox.Select(); but here I have to set a StartPosition and so on, but I want to search for String! How could I do this? (Searched stackoverflow, didn't find something similiar..) 回答1: int start = 0; int indexOfSearchText = 0; private void

C# RichTextBox Select specified Text

心已入冬 提交于 2019-12-01 18:19:39
I have a RichTextBox with -by example- this text: "This is my Text" Now I want to "search" the RichTextBox for a Text (String), by example: "Text" Now "Text" should be selected/highlighted (for each one) in the RichTextBox.. There is something like: myRichTextBox.Select(); but here I have to set a StartPosition and so on, but I want to search for String! How could I do this? (Searched stackoverflow, didn't find something similiar..) int start = 0; int indexOfSearchText = 0; private void btnFind_Click(object sender, EventArgs e) { int startindex = 0; if(txtSearch.Text.Length > 0) startindex =

Format words in RichTextBox

人走茶凉 提交于 2019-12-01 17:27:41
问题 I am using the following code to find each line that starts with "@" and format it by making it bold: foreach (var line in tweetText.Document.Blocks) { var text = new TextRange(line.ContentStart, line.ContentEnd).Text; line.FontWeight = text.StartsWith("@") ? FontWeights.Bold : FontWeights.Normal; } However, I would like to use the code to find each word instead of line beginning with "@" so I could format a paragraph like: Blah blah blah @username blah blah blah blah @anotherusername 回答1:

RichTextBox and Inserting at Caret Positions

爷,独闯天下 提交于 2019-12-01 17:21:26
Here is the deal: I have a RichTextBox control and it works fine. The problem is that there is a button "Insert Current DateTime" which adds/injects the current datetime into the RichTextBox. The user can enter the datetime anywhere where the caret is pointing. This involves complicated string manipulation and stuff. Any ideas how to get the current caret position. Whenever I get RichTextBox.CaretPositon it seems it is pointing to the start of the RichTextBox and not where the actual caret is. UPDATE 1: The date time button click code: private void DateTimeStampButton_Click(object sender,

Does WPF's TextBox support spell-check dictionaries for the Netherlands?

廉价感情. 提交于 2019-12-01 17:12:08
The RichTextBox supports a spellcheck option which is very nice. (SpellCheck.IsEnabled = true) But I cannot seem to get it to another language. (I live in the Netherlands.. ;)) Does any of you have an experience with the SpellCheck option of TextBox? I know it can be change by changing the keyboard settings, but I want to change it in the application. What I have tried so far (and did not work): Changing the CurrentCulture on the current Thread. Changing the Language property in xaml in "nl-NL" Changing the Language property in code with the XmlLanguage.GetLanguage("nl-NL"); You should not get

RichTextBox and Inserting at Caret Positions

强颜欢笑 提交于 2019-12-01 16:46:47
问题 Here is the deal: I have a RichTextBox control and it works fine. The problem is that there is a button "Insert Current DateTime" which adds/injects the current datetime into the RichTextBox. The user can enter the datetime anywhere where the caret is pointing. This involves complicated string manipulation and stuff. Any ideas how to get the current caret position. Whenever I get RichTextBox.CaretPositon it seems it is pointing to the start of the RichTextBox and not where the actual caret is

Breaks encoding in richtextbox

北战南征 提交于 2019-12-01 16:39:18
I use richtextbox in my winform application. When I paste "ជំរាបសួរ Khmer" text all good: But when I paste "'مرحب Arabic" text some problems appear: in the first insert having problems with the encoding: I have not found any Enсoding properties in richtextbox. How do I solve the problem of encoding? Use RichTextBox v5. The default in Visual Studio is v4. It fixes this problem among others. public class RichText50W : RichTextBox { [DllImport("kernel32.dll", CharSet = CharSet.Auto)] static extern IntPtr LoadLibrary(string lpFileName); protected override CreateParams CreateParams { get {

Windows Forms RichTextBox cursor position

心已入冬 提交于 2019-12-01 15:38:29
I have a C# Windows Forms program that has a RichTextBox control. Whenever the text inside the box is changed (other than typing that change), the cursor goes back to the beginning. In other words, when the text in the RichTextBox is changed by using the Text property, it makes the cursor jump back. How can I keep the cursor in the same position or move it along with the edited text? Thanks You can store the cursor position before making the change, and then restore it afterwards: int i = richTextBox1.SelectionStart; richTextBox1.Text += "foo"; richTextBox1.SelectionStart = i; You might also