This class adds the following functionality to RichTextBox: 1. Allows plain text to be inserted or appended programmatically to RTF content. 2. Allows the font, text color, and highlight color of plain text to be specified when inserting or appending text as RTF. 3. Allows images to be inserted programmatically, or with interaction from the user.
Many solutions to the problem of programmatically inserting images into a RichTextBox use the clipboard or hard code the RTF for the image in the program. This class is an attempt to make the process of inserting images at runtime more flexible without the overhead of maintaining the clipboard or the use of huge, cumbersome strings. RTF Specification v1.6 was used and is referred to many times in this document. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnrtfspec/html/rtfspec.asp For information about the RichEdit (Unmanaged RichTextBox) ... http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/richedit/richeditcontrols/aboutricheditcontrols.asp
Наследование: System.Windows.Forms.RichTextBox
Пример #1
0
		private void ics_ConferenceMessageReceived(object sender, string messageReceived, string fromUser)
		{
			Invoke(new MethodInvoker(delegate
			{
				var _rtBox = new ExRichTextBox();
				int _index;


				_rtBox.AppendTextAsRtf(fromUser + " Says\n",
									   new Font(this.Font, FontStyle.Bold), RtfColor.Blue);
				_rtBox.AppendTextAsRtf(messageReceived, new Font(this.Font, FontStyle.Bold), RtfColor.Gray);
				if ((_index = _rtBox.Find(":)")) > -1)
				{
					_rtBox.Select(_index, ":)".Length);
					_rtBox.InsertImage(pbSmile.Image);
				}
				chatForm.rtBox.AppendRtf(_rtBox.Rtf);
				// Scroll to bottom so newly added text is seen.
				chatForm.rtBox.Select(chatForm.rtBox.TextLength, 0);
				chatForm.rtBox.ScrollToCaret();

				// Return focus to message text box
				chatForm.txtSendMessage.Focus();
			}
			));
			
		}
Пример #2
0
 public frmChat( iConfServer.NET.iConfServerDotNet ics)
 {
     InitializeComponent();
     rtBox = new ExRichTextBox();
     rtBox.Parent = pnlFill;
     rtBox.Dock = DockStyle.Fill;
     rtBox.ReadOnly = true;
     this.ics = ics;
 }
Пример #3
0
 public frmChat(iConfServer.NET.iConfServerDotNet ics)
 {
     InitializeComponent();
     rtBox          = new ExRichTextBox();
     rtBox.Parent   = pnlFill;
     rtBox.Dock     = DockStyle.Fill;
     rtBox.ReadOnly = true;
     this.ics       = ics;
 }