RichTextBox中的文本中的工具提示 [英] ToolTip in Text inside RichTextBox

查看:95
本文介绍了RichTextBox中的文本中的工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用代码编辑器,我只想为Rich文本框(用作代码编辑器)中输入的所有文本添加工具提示.

I'm working with code editor and I just wanted to add tooltip for everytext that Ill inputed in richtextbox (served as code-editor) .

直到我在这里看到本指南:

Till I see this guide right here:

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

这是我要查找的东西,尽管我下载该文件时,有一个文件丢失了其主要形式.

It's the same thing that I want to find though the time I download it there's a file missing specifically its mainform .

所以我只想问一问不使用任何.dll文件怎么做.

So I just want to ask if how to do it without using any .dll file.

示例:我在rtb中键入"abc",然后当我将鼠标悬停在其上时出现带有文本的工具提示:这是一个字母.当我将鼠标悬停在带有文本的工具提示上时,与"123"相同:这是一个数字.

Sample: I type "abc" in rtb then when I mouse hover it a tooltip with text: this is an alphabet will appear. Same as with "123" a when I mousehover tooltip with text: this is a number will appear.

推荐答案

您可以尝试此示例,一种实现方法

You can try this Sample, 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);
            }

        }
    }
}

这篇关于RichTextBox中的文本中的工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆