richtextbox

Silverlight 4 RichTextBox - can't restore Xaml with text containing curly braces

偶尔善良 提交于 2019-12-11 09:45:26
问题 We have a Silverlight application using the RichTextBox as a rich text editor for the user to create emails. We actually have our own serializer but essentially we are saving and restoring the Xaml. As far as I can tell it is impossible to restore any text containing curly braces. You can demonstrate this fairly easily by creating a RichTextBox and typing something similar to {weird} into it. Then take the .Xaml property of the textbox and set it on the .Xaml property of another textbox -

Capture DragDrop Event of RichTextBox C#

独自空忆成欢 提交于 2019-12-11 08:38:24
问题 I have a custom RichTextBox Control derived from RichTextBox Control that Windows provides. I am unable to capture the dragDrop Event though the DragEnter event is getting captured, but I dont know why the dragDrop event is not. I have following properties set as true: EnableAutoDragDrop=true; AllowDrop=true; What am I missing ?? 回答1: Daniel is probably correct here: private void DragOver(object sender, System.Windows.Forms.DragEventArgs e) { if (!e.Data.GetDataPresent(typeof(System.String)))

How to detect URLs written or pasted in a RichTextBox in WPF application

血红的双手。 提交于 2019-12-11 08:34:00
问题 Sometimes a user will type a website URL while chatting in a Chat Application. I need to make the RichTextBox detect these URLs automatically, but I do not know how. General TextBox does not detect URLs, so i have used RichTextBox instead. I know RichTextBoxes can detect URLs but I don't know how. Can anybody suggest how I might do this? 回答1: As schoola pointed out, the WPF RichTextBox does not auto-detect URLs. However this article describes a fairly simple (150 line) implementation of a

SL 4: Monitor properties of ScrollViewer?

ぐ巨炮叔叔 提交于 2019-12-11 07:51:38
问题 We have a Canvas contained in a ScrollViewer. Users can add an unlimited number of UserControls that, to oversimplify, are a RichTextControl surrounded by a number of decorative rectangles. We have an arranger that positions all the UserControls so none overlap. When the arranger runs, it calculates a new position for each UserControl and sets its X and Y on the Canvas. Something is causing the ScrollViewer to scroll, however, so that after the arranger runs the user might have a different

Detecting a paste into a RichTextBox

时光总嘲笑我的痴心妄想 提交于 2019-12-11 07:28:36
问题 Is there some way I can detect or cause an event to fire whenever text is pasted into a RichTextBox? Or maybe there is already some kind of event that fires when text is pasted? This is Winforms C#, by the way. 回答1: Because not all people may use Ctrl+V and because there are other ways to get text into a text box (such as drag and drop), I went a different route, which I will share here in case anyone else is looking for a solution. What I did was create a field in my class: int _lastPosition

How do I display a Panel when selecting a word in a RichTextBox?

烂漫一生 提交于 2019-12-11 07:28:27
问题 When I select or double-click on a word in the RichTextBox , a panel should appear above this word (This panel is initially hidden and appears when the word is highlighted). When I remove the selection, the panel should disappear. private void richTextBox1_SelectionChanged(object sender, EventArgs e) { if (richTextBox1.SelectedText.Length > 0) panel1.Visible = true; else panel1.Visible = false; } 回答1: According to your changes, you need a custom control to achieve this. Set your custom

how can i simulate CTRL+C in C#

我怕爱的太早我们不能终老 提交于 2019-12-11 07:04:50
问题 I have the following code which works fine in notepad but not in WORD!! [DllImport("user32.dll")] public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); [DllImport("user32.dll")] public static extern IntPtr GetForegroundWindow(); [DllImport("user32.dll", SetLastError = true)] public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId); [DllImport("kernel32.dll")] public static extern uint GetCurrentThreadId(); [DllImport("user32.dll")] public static

WinForms RichTextBox: how to perform a formatting on TextChanged?

岁酱吖の 提交于 2019-12-11 06:47:14
问题 I have a RichTextBox that I want to re-format when the contents of the RichTextBox changes. I have a TextChanged event handler. The re-formatting (changing colors of selected regions) triggers the TextChanged event. It results in a never-ending loop of TextChange event, reformat, TextChange event, reformat, and so on. How can I distinguish between text changes that result from the app, and text changes that come from the user? I could check the text length, but not sure that is quite right.

Call RichTextBox.ScrollToEnd() from View Model class

牧云@^-^@ 提交于 2019-12-11 06:36:37
问题 Hi I try solve this, in WPF I use Caliburn Micro framework. In View I have bindable richtextbox control, I bind from view model class property type of FlowDocument. I need have a way how can I call method ScrollToEnd on richetextbox control in view. Is it possible? Because in view model class I don’t have instance of richtextbox. Thank for idead. 回答1: A similar question is asked here with a solution. http://social.msdn.microsoft.com/Forums/en/wpf/thread/67b618aa-f62e-43f8-966c-48057f4d4e0c

Windows Form RTF formatting for the RichTextBox Control

寵の児 提交于 2019-12-11 06:16:33
问题 I'm working on a windows form application and I want to have a rich text box display the status of events that are firing based on different objects. I want to be able to format the items as they come into the rtb using the rtf property so that they can be easily distinguished from each other by changing font weight and color. The format would contain <b><datetime></b> - <colored text>Event Type</colored text> - <plain text>Event Details</plain text> I've been doing a lot of research on RTF