private void txtCopySend_KeyDown(object sender, KeyEventArgs e) { var ctrl = sender as TextBox; if (e.KeyData == Keys.Delete) { if (ctrl.SelectionLength == 0) { e.Handled = true; if (ctrl.Text.Length == ctrl.SelectionStart) { return; } var nLen = ctrl.Text.Length; var address = new EmailAddressUtil(ctrl.Text, ';', ctrl.SelectionStart); var itemIndex = address.GetSelectedItemIndex(); var subAddress = address.DeleteSelectedItemAt(itemIndex); ctrl.Text = subAddress.Str; ctrl.SelectionStart = subAddress.Pos; ctrl.SelectionLength = 0; } } }
private void txtCopySend_Click(object sender, EventArgs e) { _txtBox = sender as TextBox; var address = new EmailAddressUtil(txtboxCC.Text, ';', txtboxCC.SelectionStart); int nStart = 0, nLen = 0; address.GetSelectedItemSection(ref nStart, ref nLen); if (txtboxCC.TextLength != txtboxCC.SelectionStart) { txtboxCC.SelectionStart = nStart; txtboxCC.SelectionLength = nLen; } }
private void txtCopySend_KeyPress(object sender, KeyPressEventArgs e) { var ctrl = sender as TextBox; if (e.KeyChar == (char)Keys.Back) { if (ctrl.SelectionLength == 0) { e.Handled = true; var address = new EmailAddressUtil(ctrl.Text, ';', ctrl.SelectionStart); var itemIndex = address.GetSelectedItemIndex(); var subAddress = address.BackSelectedItemAt(itemIndex); ctrl.Text = subAddress.Str; ctrl.SelectionStart = subAddress.Pos; ctrl.SelectionLength = 0; } } }