2013-04-15 13 views
0

即時通訊工具與代碼編輯器,我只是想爲richtextbox(作爲代碼編輯器)中輸入的每種文本添加工具提示。RichTextBox中的文本中的工具提示

「直到我看到這個指南就在這裏:

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

它,我想找到雖然我下載的時候那裏有一個專門的文件丟失它的MainForm同樣的事情。

所以我只想問如果不使用任何.dll文件如何做到這一點。

示例:我在rtb中鍵入「abc」,然後當我將鼠標懸停在文本提示框上時:這是一個字母表。與「123」相同,當我mousehover工具提示與文本:這是一個數字將出現。

真的需要幫助,並且提前感謝了很多。GodBless!

+0

當我鍵入「C#是真棒」,你只需要在工具提示或全句得到真棒 –

+0

不同的文本,因爲我rtb輸入可能是如果可能的話。如果我輸入「C#Awesome」工具提示信息「它的真棒」會出現。就像那樣...就像鏈接中顯示的內容,但它在我的確定,如果它只是一個簡單的工具提示,並沒有邊界... – Elegiac

+0

「它真的」是Commmon的單詞必須附在RTB中輸入的最後一個單詞上。請告訴我樣本輸入輸出 –

回答

0

你可以試試這個樣品,一種方法來實現

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

你在RTB,希望
+0

@Akyshay Joy rtbTypedText不存在maam – Elegiac

+0

請在全球範圍內聲明變異 –

+0

我還添加了ToolTip toolTip1 = new ToolTip();它已經運行但沒有變化...... :( – Elegiac