richtextbox

Custom RichTextBox Event Handle

十年热恋 提交于 2019-12-02 14:44:34
问题 I'm new to Custom Controls and I'm looking for some help. I want to know if it is possible to add validation on an event such as a "Key_Press" within my Custom Class rather than through an Event in my form code. I aim to block the use of the Return & Enter keys for the control. I have created a custom RichTextBox, code below :- public class CustomRTB : RichTextBox { protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if ((keyData == (Keys.Control | Keys.V))) { IDataObject

How do I send varying text sized strings from one RichTextBox to another?

旧时模样 提交于 2019-12-02 14:33:03
问题 I have code that has chemical compounds that have small font for the subscript. I currently have this code that transfers it from one RichTextBox to another one on a Button click. myRichTextBox.Text += otherRichTextBox.Text In otherRichTextBox I have the compound with varying font sizes however when I do this I end up with a string in myRichTextBox that doesn't keep the varying font sizes and sets them all to the boxes main properties font and size. 回答1: From the documentation on msdn: "The

Save text from rich text box with C#

两盒软妹~` 提交于 2019-12-02 14:15:17
This question has been answered. I've improved the code a bit (at least I think so). It now reminds of the aceepted answer to the question Open file in rich text box with C# . If I haven't made any mistakes (which I may have), the code should save a file with text from the rich text box rtfMain. The default file extension is .txt. You can also use the file extension .rtf. private void menuFileSave_Click(object sender, EventArgs e) { // Create a new SaveFileDialog object using (SaveFileDialog dlgSave = new SaveFileDialog()) try { // Default file extension dlgSave.DefaultExt = "txt"; //

How to detect multiline paste in RichTextBox

我怕爱的太早我们不能终老 提交于 2019-12-02 12:59:23
问题 At the moment I'm working on a simple syntax highlighter and I have couple of problems. Could you help me out? I have a class library with a component class in it. Everything is in VB.NET. It's only one file so you can see it here https://gist.github.com/2366507 . On line 92, there is the OnTextChanged Sub. I was thinking about adding ProcessAllLines() (as on line 128) to the end of that Sub, and it worked. However when I was typing in code to the RichTextBox (source which I used is here

Creating a newline in rich text box

别等时光非礼了梦想. 提交于 2019-12-02 12:29:37
问题 I need help on creating a new line for my RichTextBox which I cant make work when using CheckBox. It keeps overlapping instead of creating a newline of words. Tried using the method of rtbdisplay.text = (display+envrionment.newline); example from my code: if (rbtnSmall.Checked == true) { rtbDisplay.Text = "displaytext".PadRight(20) + "size".PadRight(23) + qty.ToString().PadRight(20) + StrongDummy; } 回答1: Use the RichTextBox.Text property or the RichtTextBox.AppendText method to append a

How to get scroll position for RichTextBox?

谁说我不能喝 提交于 2019-12-02 11:39:25
问题 I'm working in C#, Windows Forms application, and have a problem getting scroll position for RichTextBox with large amount of text. I'm using this code: public class POINT { public int x; public int y; public POINT() { } public POINT(int x, int y) { this.x = x; this.y = y; } } SendMessage(this.Handle, EM_GETSCROLLPOS, 0, res) But, when control contains large amount of text, resulting y offset is incorect because upper 16 bits of Y are always 0. Is there any way to get scroll position larger

Richtextbox prepend new text with color

老子叫甜甜 提交于 2019-12-02 11:37:43
问题 I have used a richtextbox to display logs in my WinForms. Language used is C#. The software is used for inserting data of Bank Branches and after start of new Branch I want to display a text with new color. I have seen the link Color different parts of a RichTextBox string and implemeted it successfully. My problem is I want to prepend the new line instead of append. That is the new line will be displayed on top. I am able to do this by changing the code to box.Text=DateTime.Now.ToString("dd

How do I send varying text sized strings from one RichTextBox to another?

六眼飞鱼酱① 提交于 2019-12-02 10:18:14
I have code that has chemical compounds that have small font for the subscript. I currently have this code that transfers it from one RichTextBox to another one on a Button click. myRichTextBox.Text += otherRichTextBox.Text In otherRichTextBox I have the compound with varying font sizes however when I do this I end up with a string in myRichTextBox that doesn't keep the varying font sizes and sets them all to the boxes main properties font and size. From the documentation on msdn: "The Text property does not return any information about the formatting applied to the contents of the RichTextBox

Color a Specific Word in every richtextbox line VB

南楼画角 提交于 2019-12-02 08:29:02
问题 I want to color every same word inside a richtextbox . I can do it for one line but not on multiple lines. Ex. Welcome "user" ..... I want the word user to be an exact color in every line it is in. Here's with what i came up so far: RichTextBox1.Text = "Welcome " RichTextBox1.Select(RichTextBox1.TextLength, 0) RichTextBox1.SelectionColor = My.Settings.color RichTextBox1.AppendText(My.Settings.username) RichTextBox1.SelectionColor = Color.Black RichTextBox1.AppendText(" ........." + vbCrLf) It

Override ShortCut Keys on .NET RichTextBox

拥有回忆 提交于 2019-12-02 07:40:33
问题 I'm using a RichTextBox (.NET WinForms 3.5) and would like to override some of the standard ShortCut keys.... For example, I don't want Ctrl+I to make the text italic via the RichText method, but to instead run my own method for processing the text. Any ideas? 回答1: Ctrl + I isn't one of the default shortcuts affected by the ShortcutsEnabled property. The following code intercepts the Ctrl + I in the KeyDown event so you can do anything you want inside the if block, just make sure to suppress