Tooltip in text inside RichTextBox

im works with a code editor, and I just wanted to add a tooltip for each text that Ill entered in the richtextbox (served as a code editor).

'until I see this guide right here:

http://www.codeproject.com/Articles/464085/WinForms-RichTextBox-ToolTip-like-Visual-Studios

its the same that I want to find, although the time when I upload it is a file that is not specifically in its main form.

so I just want to ask how to do this without using any dll file.

sample: I type "abc" in rtb, then when the mouse hover over it with a tooltip with the text: the alphabet will appear. same as with "123" a, when I mousehover tooltip with text: this number will appear.

really need help and thanks in advance .GodBless!

0
source share
1 answer

You can try this example, one way to achieve

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication3 { public partial class Form1 : Form { public string rtbTypedText = ""; public Form1() { InitializeComponent(); } private void richTextBox1_Leave(object sender, EventArgs e) { // MessageBox.Show(text); } private void richTextBox1_KeyPress(object sender, KeyPressEventArgs e) { if (char.IsWhiteSpace(e.KeyChar)) { int result = 0; string s = richTextBox1.Text; string text = ""; string[] sp = s.Split(' '); if (sp.Length == 0) rtbTypedText = s; else rtbTypedText = sp[sp.Length - 1]; bool typeStatus = int.TryParse(rtbTypedText, out result); if (typeStatus == true) toolTip1.Show("It is a Number", richTextBox1); else toolTip1.Show("It is an Alphabet", richTextBox1); } } } } 

enter image description here

0
source

Source: https://habr.com/ru/post/1498299/


All Articles