こんにちはマスター/プログラマーです。
Split() を使用しようとしています。使用後、RTB の入力 == 私のポイントかどうかを確認してから、RTB のフォントの色を変更します。この例のように。
RTBの入力:Chelsea is my favorite football club. I like playing football
私のポイント:football.
次に、入力を分割し、各インデックスで分割の結果を確認します。
最後に、例を見つけました:arr[4] and [9] = football
では、RTB画面で
「チェルシーが好きfootball
。クラブで遊ぶのが好き」のようにフォントの色を変えるにはfootball
?
この私のコード例:
ArrayList arrInput = new ArrayList();
//if the input Chelsea is my favorite football club. I like playing football
string allInput = rtbInput.Text;
string[] splitString = allInput.Split(new char[] { ' ', '\t', ',', '.'});
foreach (string s in splitString)
{
if (s.Trim() != "")
{
int selectionStart = s.ToLower().IndexOf("football");
if (selectionStart != -1)
{
rtbInput.SelectionStart = selectionStart;
rtbInput.SelectionLength = ("football").Length;
rtbInput.SelectionColor = Color.Red;
}
}
//What Next?? Im confused. We know that football on arrInput[4].ToString() and [9]
//How to change font color on RTB screen when the input == football