0

私はコードエディターを使用していますが、リッチテキストボックス (コードエディターとして機能) に入力したすべてのテキストにツールチップを追加したかっただけです。

ここでこのガイドを見るまで:

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

それは私が見つけたいのと同じものですが、ダウンロードするときに特にそのメインフォームが欠落しているファイルがあります。

だから、.dllファイルを使わずにそれを行う方法を尋ねたいだけです。

サンプル: rtb に「abc」と入力し、マウスをホバーするとテキスト付きのツールチップが表示されます。これはアルファベットです。「123」と同じように、ツールチップにテキストをマウスオーバーすると、これは数字が表示されます。

4

1 に答える 1

0

このサンプルを試すことができます。達成するための 1 つの方法

   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);
            }

        }
    }
}

ここに画像の説明を入力

于 2013-04-15T06:42:45.387 に答える