private void processKbdCtrlShortcuts(object sender, KeyEventArgs e) { TextBoxBase t = (TextBoxBase)sender; if (e.KeyData == (Keys.C | Keys.Control)) { t.Copy(); e.Handled = true; } else if (e.KeyData == (Keys.X | Keys.Control)) { t.Cut(); e.Handled = true; } else if (e.KeyData == (Keys.V | Keys.Control)) { t.Paste(); e.Handled = true; } else if (e.KeyData == (Keys.A | Keys.Control)) { t.SelectAll(); e.Handled = true; } else if (e.KeyData == (Keys.Z | Keys.Control)) { t.Undo(); e.Handled = true; } }
private void TextBox_KeyDown(object sender, KeyEventArgs e) { TextBoxBase tbx = sender as TextBoxBase; if (tbx != null && e.KeyCode == Keys.Enter) { tbx.SelectAll(); switch (tbx.Name) { case "tbxTitle": mskStock.Focus(); break; case "mskStock": tbxProducer.Focus(); break; case "tbxProducer": tbxDirector.Focus(); break; case "tbxDirector": tbxStarring.Focus(); break; case "tbxStarring": mskProductionYear.Focus(); break; case "mskProductionYear": rdoAction.Focus(); break; } } }
// Perform the command associated with MenuIndex on the specified TextBoxBase. private void DoTextBoxCommand(TextBoxBase textbox, MenuIndex menuIndex) { switch (menuIndex) { case MenuIndex.Undo: textbox.Undo(); break; case MenuIndex.Redo: if (textbox is RichTextBox) { RichTextBox rt = (RichTextBox)textbox; rt.Redo(); } break; case MenuIndex.Cut: textbox.Cut(); break; case MenuIndex.Copy: textbox.Copy(); break; case MenuIndex.Paste: textbox.Paste(); break; case MenuIndex.Delete: textbox.SelectedText = ""; break; case MenuIndex.SelectAll: textbox.SelectAll(); break; case MenuIndex.Properties: break; } }
public override void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { // If we don't have a control, return if (sender is TextBoxBase) { TextBoxBase control = (TextBoxBase)sender; if ((bool)e.NewValue) { // Focus this control control.Focus(); // Select all text control.SelectAll(); } } if (sender is PasswordBox) { PasswordBox password = (PasswordBox)sender; if ((bool)e.NewValue) { // Focus this control password.Focus(); // Select all text password.SelectAll(); } } }
private void selectAllToolStripMenuItem_Click(object sender, EventArgs e) { if (ActiveControl is TextBoxBase) { TextBoxBase tb = (TextBoxBase)ActiveControl; tb.SelectAll(); } }
private void tbtemplate_KeyDown(object sender, KeyEventArgs e) { if (e.Control == true && e.KeyCode == Keys.A) { TextBoxBase textBox = (TextBoxBase)sender; textBox.SelectAll(); } }
public static void Focus(DependencyObject baseObject, TextBoxBase element) { FocusManager.SetFocusedElement(baseObject, element); Delay(baseObject, 16, () => { element.SelectAll(); Keyboard.Focus(element); }); }
private static void OnSelectAll(object sender, RoutedEventArgs e) { TextBoxBase box = sender as TextBoxBase; if (box != null) { box.SelectAll(); } }
public void SelectAll() { TextBoxBase textBox = FindFocusedTextBox(); if (textBox != null) { textBox.SelectAll(); } }
public static bool ParseInputH(TextBoxBase control, out ulong value) { if (!ulong.TryParse(control.Text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out value)) { control.Focus(); control.SelectAll(); return(false); } return(true); }
public static bool ParseInputD(TextBoxBase control, out ulong value) { if (!ulong.TryParse(control.Text, out value)) { control.Focus(); control.SelectAll(); return(false); } return(true); }
public void SelectAll() { if (isFc) { fc.SelectAll(); } else { tb.SelectAll(); } }
private static void TrySet(TextBoxBase textBox, bool value) { if (value) { textBox.GotKeyboardFocus += async(s, a) => { await Task.Delay(20).ConfigureAwait(true); // Quite ugly but required to make it work textBox.SelectAll(); }; } }
private void DoCredentialsFocussed(object sender, RoutedEventArgs e) { TextBoxBase tb = sender as TextBoxBase; if (tb == null) { PasswordBox pwb = sender as PasswordBox; pwb.SelectAll(); } else { tb.SelectAll(); } }
/// <summary> /// Handles the key down event for the text controls. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.Windows.Forms.KeyEventArgs"/> instance containing the event data.</param> private void TextKeyDown(object sender, KeyEventArgs e) { TextBoxBase textBox = sender as TextBoxBase; if (textBox == null) { return; } if (e.Control && e.KeyCode == Keys.A) { textBox.SelectAll(); } }
protected override void OnPreviewGotKeyboardFocus(KeyboardFocusChangedEventArgs e) { // if event is called from ComboBox itself and not from any of underlying controls // and if textBox is defined in control template if (e.OriginalSource == e.Source && textBox != null) { textBox.Focus(); textBox.SelectAll(); e.Handled = true; } else { base.OnPreviewGotKeyboardFocus(e); } }
private void ValidatingTextBox(TextBoxBase control, CancelEventArgs e) { if (!control.Enabled) { return; } if (control.Text.Length != 0) { return; } e.Cancel = true; control.SelectAll(); errorProvider1.SetError(control, "Text box cannot be empty"); }
private static void SelectAllText(this TextBoxBase textBoxBase) { if (textBoxBase is System.Windows.Controls.TextBox textBox) { if (textBox.SelectedText == textBox.Text) { return; } textBox.SelectAll(); return; } if (!textBoxBase.IsSelectionActive) { textBoxBase.SelectAll(); } }
/// <summary> /// Traite l'évènement GotFocus de l'élément associé. /// </summary> /// <param name="sender">La source de l'évènement.</param> /// <param name="e">Les <see cref="System.Windows.RoutedEventArgs"/> contenant les données de l'évènement.</param> void AssociatedObject_GotFocus(object sender, System.Windows.RoutedEventArgs e) { TextBoxBase textBox = (TextBoxBase)AssociatedObject; // Sélectionne tout le textbox lorsqu'il a le focus Dispatcher.BeginInvoke ( DispatcherPriority.ContextIdle, new Action ( () => { textBox.SelectAll(); textBox.ReleaseMouseCapture(); } ) ); }
private void FixMicrosoft(object sender, KeyPressEventArgs e) { // stop annoying beep due to parent not having an AcceptButton if ((e.KeyChar == (char)Keys.Enter) || (e.KeyChar == (char)Keys.Escape)) { e.Handled = true; } // enable Ctrl+A to SelectAll in TextBox and RichTextBox if ((ModifierKeys == Keys.Control) && (e.KeyChar == (char)1)) { TextBoxBase control = (sender as TextBoxBase); if (control != null) { control.SelectAll(); e.Handled = true; } } }
private static void FocusTextBox(TextBoxBase textBox) { DeferredAction.Create(context => { if (textBox == null || Application.Current == null || Application.Current.MainWindow == null) { return; } textBox.Focus(); textBox.SelectAll(); FocusManager.SetFocusedElement(Application.Current.MainWindow, textBox); Keyboard.Focus(textBox); if (textBox.IsVisible == false || textBox.IsKeyboardFocused) { context?.Dispose(); } else { context?.Defer(TimeSpan.FromSeconds(0.25)); } }).Defer(TimeSpan.FromSeconds(0.25)); }
//Handles GotFocus for several text boxes private static void Text_Focus(TextBoxBase textBox) { textBox.SelectAll(); }
public static void TextAutoSelectText(TextBoxBase sender) { sender.SelectAll(); }
public static void SetSelect(this TextBoxBase textBox) { textBox.Focus(); textBox.SelectAll(); }
public static void FocusAndSelectAll(this TextBoxBase s) { s.Enabled = true; s.Focus(); s.SelectAll(); }
// Token: 0x060002FC RID: 764 RVA: 0x0000337E File Offset: 0x0000157E static void smethod_17(TextBoxBase textBoxBase_0) { textBoxBase_0.SelectAll(); }
public static void ProcessTextContextMenu(TextBoxBase textbox, object sender) { var tsmi = sender as ToolStripMenuItem; if (tsmi == null) { return; } var cmd = tsmi.Tag as string; var text = string.Empty; try { if (cmd == FormStringKeys.STR_MENU_ITEM_COPY_ALL.ToString()) { if (textbox.Text != "") { Clipboard.SetText(textbox.Text); } } else if (cmd == FormStringKeys.STR_MENU_ITEM_COPY.ToString()) { if (textbox.SelectedText != "") { Clipboard.SetText(textbox.SelectedText); } } else if (cmd == FormStringKeys.STR_MENU_ITEM_CUT.ToString()) { if (textbox.SelectedText != "") { textbox.Cut(); } } else if (cmd == FormStringKeys.STR_MENU_ITEM_PASTE.ToString()) { if (Clipboard.ContainsText()) { //TODO no RTF textbox.Paste(); } } else if (cmd == FormStringKeys.STR_MENU_ITEM_SELECT_ALL.ToString()) { textbox.Focus(); textbox.SelectAll(); } else if (cmd == FormStringKeys.STR_MENU_ITEM_CLEAR.ToString()) { textbox.Clear(); } else if (cmd == FormStringKeys.STR_MENU_ITEM_DELETE.ToString()) { if (textbox.SelectionLength > 0) { var oldStart = textbox.SelectionStart; textbox.Text = textbox.Text.Remove(textbox.SelectionStart, textbox.SelectionLength); textbox.SelectionStart = oldStart; } } else if (cmd == FormStringKeys.STR_MENU_ITEM_SAVE.ToString()) { var sfd = new SaveFileDialog(); sfd.Filter = ResxManager.GetResourceString(FormStringKeys.STR_TEXT_SAVE_FILTER); if (sfd.ShowDialog() == DialogResult.OK) { File.WriteAllText(sfd.FileName, textbox.Text); } } else if (cmd == FormStringKeys.STR_MENU_ITEM_WORDWRAP.ToString()) { textbox.WordWrap = !tsmi.Checked; } else if (cmd == FormStringKeys.STR_MENU_ITEM_SEND_TO_SOURCE.ToString()) { //TODO STR_MENUITEM_SEND_TO_SOURCE } else if (cmd == FormStringKeys.STR_MENU_ITEM_UNDO.ToString()) { if (textbox.CanUndo) { textbox.Undo(); } } else if (cmd == FormStringKeys.STR_MENU_ITEM_COPY_AS_REGEX.ToString()) { text = textbox.SelectedText; if (text != string.Empty) { IRegexAnalyst ra = new RegexAnalyst(); text = ra.ToSimpleRegexString(text); Clipboard.SetText(text); } } else if (cmd == FormStringKeys.STR_MENU_ITEM_TO_REGEX_FORMAT.ToString()) { text = textbox.SelectedText; if (text == string.Empty) { text = textbox.Text; } if (text != string.Empty) { IRegexAnalyst ra = new RegexAnalyst(); text = ra.ToSimpleRegexString(text); if (textbox.SelectedText.Length > 0) { if (text != textbox.SelectedText) { //TODO it can be undo,but affect the clipboard Clipboard.SetText(text); textbox.Paste(); Clipboard.Clear(); } } else { if (text != textbox.Text) { //TODO it can be undo,but affect the clipboard Clipboard.SetText(text); textbox.SelectAll(); textbox.Paste(); Clipboard.Clear(); } } } } else if (cmd == FormStringKeys.STR_MENU_ITEM_SELECTION_ONLY.ToString()) { tsmi.Checked = !tsmi.Checked; //textbox.HideSelection = !tsmi.Checked; } } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
public void SelectAll() { textBox.SelectAll(); }
public static void FocusAndSelectAll(this TextBoxBase control) { control.Focus(); control.SelectAll(); }
public static void activeEdit(TextBoxBase edit) { edit.Focus(); edit.SelectAll(); }