| 1:2:
 3:
 4:
 5:
 6:
 7:
 8:
 9:
 10:
 11:
 12:
 13:
 14:
 15:
 16:
 17:
 18:
 19:
 20:
 21:
 22:
 23:
 24:
 25:
 26:
 27:
 28:
 29:
 30:
 31:
 32:
 33:
 34:
 35:
 36:
 37:
 38:
 39:
 40:
 41:
 42:
 43:
 44:
 45:
 46:
 47:
 48:
 49:
 50:
 51:
 52:
 53:
 54:
 55:
 56:
 57:
 58:
 59:
 60:
 61:
 62:
 63:
 64:
 65:
 66:
 67:
 68:
 69:
 70:
 71:
 72:
 73:
 74:
 75:
 76:
 77:
 78:
 79:
 80:
 81:
 82:
 83:
 84:
 85:
 86:
 87:
 88:
 89:
 90:
 91:
 92:
 93:
 94:
 95:
 96:
 97:
 98:
 99:
 100:
 101:
 102:
 103:
 104:
 105:
 106:
 107:
 108:
 109:
 110:
 111:
 112:
 113:
 114:
 115:
 116:
 117:
 118:
 119:
 120:
 121:
 122:
 123:
 124:
 125:
 126:
 127:
 128:
 129:
 130:
 131:
 132:
 133:
 134:
 135:
 136:
 137:
 138:
 139:
 140:
 141:
 142:
 143:
 144:
 145:
 146:
 147:
 148:
 149:
 150:
 151:
 152:
 153:
 154:
 155:
 156:
 157:
 158:
 159:
 160:
 161:
 162:
 163:
 164:
 165:
 166:
 167:
 168:
 169:
 170:
 171:
 172:
 173:
 174:
 175:
 176:
 177:
 178:
 179:
 180:
 181:
 182:
 183:
 184:
 185:
 186:
 187:
 188:
 189:
 190:
 191:
 192:
 193:
 194:
 195:
 196:
 197:
 198:
 
 | using System;using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
 using System.Drawing;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows.Forms;
 
 namespace WindowsFormsApplication3
 {
 public partial class Form1 : Form
 {
 string[] lex = new string[] { "one", "two", "three" };
 string ergebnis;
 public Form1()
 {
 InitializeComponent();
 
 }
 
 private void textBox1_TextChanged(object sender, EventArgs e)
 {
 int begrifflaenge = textBox1.SelectionStart;
 string schluesselwort = "";
 string tmp = textBox1.Text;
 string mein_ergebnis;
 int courserpos_tmp = textBox1.SelectionStart;
 if (courserpos_tmp == 1)
 if (tmp.Substring(0, 1) != " ")
 {
 
 schluesselwort = tmp.Substring(0, 1);
 begrifflaenge = 1;
 Console.WriteLine("1 zeichen, Anfang" + " -->>" + schluesselwort);
 }
 if (tmp.Length > 1 && tmp.Substring(tmp.Length - 2, 1) == " " && tmp.Substring(tmp.Length - 1, 1) != " ")
 {
 
 schluesselwort = tmp.Substring(tmp.Length - 1, 1);
 begrifflaenge = 1;
 Console.WriteLine("1 zeichen, Mittendrin" + " -->>" + schluesselwort);
 }
 
 if (courserpos_tmp == 2)
 if (tmp.Substring(0, 1) != " " && tmp.Substring(1, 1) != " ")
 {
 
 schluesselwort = tmp.Substring(0, 1) + tmp.Substring(1, 1);
 begrifflaenge = 2;
 Console.WriteLine("2 zeichen, Anfang" + " -->>"+ schluesselwort);
 
 }
 if (tmp.Length > 2 && tmp.Substring(tmp.Length - 3, 1) == " " && tmp.Substring(tmp.Length - 2, 1) != " " && tmp.Substring(tmp.Length - 1, 1) != " ")
 {
 
 schluesselwort = tmp.Substring(tmp.Length - 2, 1) + tmp.Substring(tmp.Length - 1, 1);
 begrifflaenge = 2;
 Console.WriteLine("2 zeichen, Mittendrin" + " -->>" + schluesselwort);
 }
 if (courserpos_tmp == 3)
 if (tmp.Substring(0, 1) != " " && tmp.Substring(1, 1) != " " && tmp.Substring(2, 1) != " ")
 {
 
 schluesselwort =  tmp.Substring(0, 1) +tmp.Substring(1, 1) + tmp.Substring(2, 1);
 begrifflaenge = 3;
 Console.WriteLine("3 zeichen, Anfang" + " -->>" + schluesselwort);
 }
 if (courserpos_tmp > 3 && tmp.Substring(tmp.Length - 4, 1) == " " && tmp.Substring(tmp.Length - 3, 1) != " " && tmp.Substring(tmp.Length - 2, 1) != " " && tmp.Substring(tmp.Length - 1, 1) != " ")
 {
 
 schluesselwort = tmp.Substring(tmp.Length - 3, 1) + tmp.Substring(tmp.Length - 2, 1) + tmp.Substring(tmp.Length - 1, 1);
 begrifflaenge = 3;
 Console.WriteLine("3 zeichen, Mittendrin" + " -->>" + schluesselwort);
 }
 if (courserpos_tmp == 4)
 if (tmp.Substring(0, 1) != " " && tmp.Substring(1, 1) != " " && tmp.Substring(2, 1) != " " && tmp.Substring(3, 1) != " ")
 {
 
 schluesselwort = tmp.Substring(0, 1) + tmp.Substring(1, 1) + tmp.Substring(2, 1) + tmp.Substring(3, 1);
 begrifflaenge = 4;
 Console.WriteLine("4 zeichen, Anfang" + " -->>" + schluesselwort);
 }
 if (courserpos_tmp > 4 && tmp.Substring(tmp.Length - 5, 1) == " " && tmp.Substring(tmp.Length - 4, 1) != " " && tmp.Substring(tmp.Length - 3, 1) != " " && tmp.Substring(tmp.Length - 2, 1) != " " && tmp.Substring(tmp.Length - 1, 1) != " ")
 {
 
 schluesselwort = tmp.Substring(tmp.Length - 4, 1) + tmp.Substring(tmp.Length - 3, 1) + tmp.Substring(tmp.Length - 2, 1) + tmp.Substring(tmp.Length - 1, 1);
 begrifflaenge = 4;
 Console.WriteLine("4 zeichen, Mittendrin" + " -->>" + schluesselwort);
 }
 if (courserpos_tmp == 5)
 if (tmp.Substring(0, 1) != " " && tmp.Substring(1, 1) != " " && tmp.Substring(2, 1) != " " && tmp.Substring(3, 1) != " " && tmp.Substring(4, 1) != " ")
 {
 
 schluesselwort = tmp.Substring(0, 1) + tmp.Substring(1, 1) + tmp.Substring(2, 1) + tmp.Substring(3, 1) + tmp.Substring(4, 1);
 begrifflaenge = 5;
 Console.WriteLine("5 zeichen, Anfang" + " -->>" + schluesselwort);
 }
 if (courserpos_tmp > 5 && tmp.Substring(tmp.Length - 6, 1) == " " && tmp.Substring(tmp.Length - 5, 1) != " " && tmp.Substring(tmp.Length - 4, 1) != " " && tmp.Substring(tmp.Length - 3, 1) != " " && tmp.Substring(tmp.Length - 2, 1) != " " && tmp.Substring(tmp.Length - 1, 1) != " ")
 {
 
 schluesselwort = tmp.Substring(tmp.Length - 5, 1) + tmp.Substring(tmp.Length - 4, 1) + tmp.Substring(tmp.Length - 3, 1) + tmp.Substring(tmp.Length - 2, 1) + tmp.Substring(tmp.Length - 1, 1);
 begrifflaenge = 4;
 Console.WriteLine("5 zeichen, Mittendrin" + " -->>" + schluesselwort);
 }
 
 
 switch (begrifflaenge)
 {
 case 1:
 mein_ergebnis = seach_the_word(schluesselwort, 1);
 if (ergebnis.Length != 0)
 {
 textBox1.Text += mein_ergebnis.Substring(1, ergebnis.Length - 1);
 textBox1.Select(courserpos_tmp, textBox1.TextLength);
 }
 textBox1.SelectionStart = courserpos_tmp;
 break;
 case 2:
 mein_ergebnis = seach_the_word(schluesselwort,2);
 if (ergebnis.Length != 0)
 {
 textBox1.Text += mein_ergebnis.Substring(2, ergebnis.Length - 2);
 textBox1.Select(courserpos_tmp, textBox1.TextLength);
 }
 textBox1.SelectionStart = courserpos_tmp;
 break;
 case 3:
 mein_ergebnis = seach_the_word(schluesselwort, 3);
 if (ergebnis.Length != 0)
 {
 textBox1.Text += mein_ergebnis.Substring(3, ergebnis.Length - 3);
 textBox1.Select(courserpos_tmp, textBox1.TextLength);
 }
 textBox1.SelectionStart = courserpos_tmp;
 break;
 case 4:
 mein_ergebnis = seach_the_word(schluesselwort, 4);
 if (ergebnis.Length != 0)
 {
 textBox1.Text += mein_ergebnis.Substring(4, ergebnis.Length - 4);
 textBox1.Select(courserpos_tmp, textBox1.TextLength);
 }
 textBox1.SelectionStart = courserpos_tmp;
 break;
 case 5:
 mein_ergebnis = seach_the_word(schluesselwort, 5);
 if (ergebnis.Length != 0)
 {
 textBox1.Text += mein_ergebnis.Substring(5, ergebnis.Length - 5);
 textBox1.Select(courserpos_tmp, textBox1.TextLength);
 }
 textBox1.SelectionStart = courserpos_tmp;
 break;
 }
 
 
 }
 string seach_the_word(string a, int laenge)
 {
 ergebnis = "";
 for (int xy =0 ;xy < 3;xy++)
 {
 if (lex[xy].Length >= laenge)
 {
 if (a == lex[xy].Substring(0, laenge))
 {
 ergebnis = (lex[xy]);
 }
 }
 
 }
 Console.WriteLine(ergebnis);
 return (ergebnis);
 }
 }
 }
 |