private void OnTextLeave(object sender, EventArgs e) { EvA_FindText ft = new EvA_FindText(TextBox.Text); if (OnLeaveTextBox != null) OnLeaveTextBox(this, ft); /* if (ft.pDestTetx.Length > 0 ) TextBox.Text = ft.pDestTetx; else TextBox.Text = string.Empty; */ TextBox.Text = ft.pDestTetx; }
private void OnKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if (OnFindByLetters == null) return; //if (TextBox.Text.Length > 0 && ((int)e.KeyChar) > 0x1F ) if (((int)e.KeyChar) > 0x1F ) { string newTxt; int selectionStart; int selectionLength; if (TextBox.SelectionStart > 0 && TextBox.SelectionStart < TextBox.Text.Length) newTxt = TextBox.Text.Substring(0,TextBox.SelectionStart) + e.KeyChar.ToString(); else newTxt = TextBox.Text + e.KeyChar.ToString(); EvA_FindText ft = new EvA_FindText(newTxt); OnFindByLetters(this, ft); if (ft.pDestTetx.Length > 0 ) { selectionStart = newTxt.Length; selectionLength = ft.pDestTetx.Length - newTxt.Length; TextBox.Text = ft.pDestTetx; TextBox.Select (selectionStart, selectionLength); //TextBox.SelectionStart = selectionStart; //TextBox.SelectionLength = selectionLength; } else { TextBox.Text = newTxt; TextBox.Select (newTxt.Length, 0); } e.Handled = true; } }