richtextbox

Adding strings to a RichTextBox in C#

别等时光非礼了梦想. 提交于 2019-12-19 04:14:32
问题 I currently have a function that will set a value to a RichTextBox, although how could you "add" a value or a new line to it, rather than overwriting existing data in the RichTextBox? richTextBox2.Text = DateTime.Today + " Hello"; 回答1: richTextBox2.AppendText(Environment.NewLine + DateTime.Today + " Hello"); 回答2: richTextBox2.AppendText(String.Format("{0} the date is {1}{2}", "Hello", DateTime.Today, Environment.NewLine)); Please don't use + 回答3: richTextBox2.Document.Blocks.Clear();

How do I move the caret a certain number of positions in a WPF RichTextBox?

…衆ロ難τιáo~ 提交于 2019-12-19 00:58:13
问题 I want to move the caret 4 positions to the right of where my caret currently is. I'm registered for PreviewKeyDown , and calling InsertTextInRun() when the tab key is captured, like so: private void rtb_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Tab) { rtb.CaretPosition.InsertTextInRun(" "); e.Handled = true; } } The problem is that the caret stays in place after the call to InsertTextInRun() . It does not move to the end of the new text, which is the behavior I want.

How to override copy and paste in richtextbox

空扰寡人 提交于 2019-12-18 16:46:19
问题 How can I override the copy/paste functions in a Richtextbox C# application. Including ctrl-c/ctrl-v and right click copy/paste. It's WPF richtextBox. 回答1: To override the command functions: protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (keyData == (Keys.Control | Keys.C)) { //your implementation return true; } else if (keyData == (Keys.Control | Keys.V)) { //your implementation return true; } else { return base.ProcessCmdKey(ref msg, keyData); } } And right

How to Make RichTextBox Text Only? [duplicate]

佐手、 提交于 2019-12-18 13:36:58
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: How to prevent richTextBox to paste images within it? If you're using Richtextbox , there are several advantages in Richtextbox for example: we can use color font on it Setting custom font in a region Attach files on it.. etc take a look at the picture: Here is my problem: Can i just make it text only? In my project, attach file or the like is unnecessary at all. I even didn't want attach or paste an images on

RichTextBoxAppender using log4net

可紊 提交于 2019-12-18 12:03:38
问题 Is there a way to programatically create a RichTextBoxAppender using log4net? In other words no xml app.config? 回答1: using System; using System.Windows.Forms; using System.Drawing; using log4net; using log4net.Core; using log4net.Appender; using log4net.Util; namespace Vip.Logging { /// <summary> /// Description of RichTextBoxAppender. /// </summary> public class RichTextBoxAppender : AppenderSkeleton { #region Private Instance Fields private RichTextBox richTextBox = null; private Form

Problems implementing TinyMCE in CodeIgniter

时光总嘲笑我的痴心妄想 提交于 2019-12-18 09:49:48
问题 I am trying to implement TinyMCE in CodeIgniter. I've created a view file and called it from a controller. I have uploaded all files into my CI project folder and showed the path of the files. But it is not working. Here is the view file: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Full featured example</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <!--

Highlight specific text in richtextbox

我们两清 提交于 2019-12-18 09:48:21
问题 I have a window form that contain a listbox and some richtextboxex . listbox contains some values. When I select any value from listbox , richtextboxex bind with data according to selected value. I have to highlight some text which is bind to richtextbox when I select a value from listbox, e.g.: Just a friendly reminder that you have <<OverdueInvCount>> overdue invoice(s), with an overdue balance of <<OverdueInvTotal>>. If you have any questions about the amount you owe, please give us a call

Replace all text in a rich text box

寵の児 提交于 2019-12-18 09:08:09
问题 I have a problem while trying to replace all text matching a particular word in a rich text box . This is the code i use public static void ReplaceAll(RichTextBox myRtb, string word, string replacer) { int index = 0; while (index < myRtb.Text.LastIndexOf(word)) { int location = myRtb.Find(word, index, RichTextBoxFinds.None); myRtb.Select(location, word.Length); myRtb.SelectedText = replacer; index++; } MessageBox.Show(index.ToString()); } private void btnReplaceAll_Click(object sender,

Replace all text in a rich text box

扶醉桌前 提交于 2019-12-18 09:08:06
问题 I have a problem while trying to replace all text matching a particular word in a rich text box . This is the code i use public static void ReplaceAll(RichTextBox myRtb, string word, string replacer) { int index = 0; while (index < myRtb.Text.LastIndexOf(word)) { int location = myRtb.Find(word, index, RichTextBoxFinds.None); myRtb.Select(location, word.Length); myRtb.SelectedText = replacer; index++; } MessageBox.Show(index.ToString()); } private void btnReplaceAll_Click(object sender,

How to prevent richTextBox to paste images within it? [duplicate]

回眸只為那壹抹淺笑 提交于 2019-12-18 07:00:42
问题 This question already has answers here : How can I prevent system clipboard image data being pasted into a WPF RichTextBox (3 answers) Closed 4 years ago . I am programming in c#. and I've a richTextBox on it. At runtime, I insert some Bitmap images into richTextbox by coding. But I want to prevent user that drag my inserted Images or paste some other images in richTextBox. How can I implement that? thanks in advance! 回答1: If you want to just allow plain text pasted from the clipboard then