Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void TextBox1_TextChanged(object sender, EventArgs e)
- {
- int first = this.textBox1.TextLength;
- string padrao = "asdfjdkjdfColocar esse texto no TextBoxqewprqewriworuoewi";
- string textIndex = padrao.Remove(0, padrao.IndexOf(this.textBox1.Text, 0) + this.textBox1.TextLength);
- this.textBox1.Text = this.textBox1.Text.Insert(this.textBox1.Text.Length, textIndex);
- this.textBox1.Select(first, this.textBox1.Text.Length);
- }
- public Form1()
- {
- InitializeComponent();
- this.textBox1.AutoCompleteMode = AutoCompleteMode.Append;
- this.textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
- AutoCompleteStringCollection stringCollection = new AutoCompleteStringCollection
- {
- "asdfjdkjdfColocar esse texto no TextBoxqewprqewriworuoewi"
- };
- textBox1.AutoCompleteCustomSource = stringCollection;
- }
- string typed = "";
- private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
- {
- string padrao = "asdfjdkjdfColocar esse texto no TextBoxqewprqewriworuoewi";
- e.Handled = true;
- // TODO:: tratamento de delete, backspace, escape etc
- typed += ((char)e.KeyChar).ToString();
- this.textBox1.Text = typed;
- int indexOf = padrao.IndexOf(typed, StringComparison.OrdinalIgnoreCase);
- if (indexOf >= 0)
- {
- this.textBox1.Text += padrao.Substring(indexOf + typed.Length);
- }
- this.textBox1.SelectionStart = typed.Length;
- this.textBox1.SelectionLength = this.textBox1.Text.Length - typed.Length;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement