你可以試試這個樣品,一種方法來實現
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);
}
}
}
}
你在RTB,希望
當我鍵入「C#是真棒」,你只需要在工具提示或全句得到真棒 –
不同的文本,因爲我rtb輸入可能是如果可能的話。如果我輸入「C#Awesome」工具提示信息「它的真棒」會出現。就像那樣...就像鏈接中顯示的內容,但它在我的確定,如果它只是一個簡單的工具提示,並沒有邊界... – Elegiac
「它真的」是Commmon的單詞必須附在RTB中輸入的最後一個單詞上。請告訴我樣本輸入輸出 –