コード例 #1
0
 void textBox1_GotFocus(object sender, EventArgs e)
 {
     // Select all text only if the mouse isn't down.
     // This makes tabbing to the textbox give focus.
     if (MouseButtons == MouseButtons.None)
     {
         box.SelectAll();
         alreadyFocused = true;
     }
 }
コード例 #2
0
 internal static void SelectAllText(this System.Windows.Controls.TextBox tb)
 {
     tb.Dispatcher.BeginInvoke(
         new Action(delegate
     {
         tb.SelectAll();
     }), System.Windows.Threading.DispatcherPriority.Input);
 }
コード例 #3
0
ファイル: Spinner.cs プロジェクト: superdino123/WPFText
        /// <summary>
        /// Handles key tip pressed
        /// </summary>
        public override void OnKeyTipPressed()
        {
            if (!IsTemplateValid()) return;

            // Use dispatcher to avoid focus moving to backup'ed element 
            // (focused element before keytips processing)
            Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle,
                (ThreadStart)(() =>
                {
                    textBox.SelectAll();
                    textBox.Focus();
                }));
            base.OnKeyTipPressed();
        }
コード例 #4
0
 static void frameworkElement_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     if (((bool)e.NewValue))
     {
         if (sender is System.Windows.Controls.TextBox)
         {
             System.Windows.Controls.TextBox textBox = sender as System.Windows.Controls.TextBox;
             if (textBox != null)
             {
                 textBox.SelectAll();
             }
         }
         ((FrameworkElement)sender).Focus();
     }
 }
コード例 #5
0
        public static bool ValidateDouble(this TextBox textBox, bool ignoreIfEmpty)
        {
            if (ignoreIfEmpty && string.IsNullOrEmpty(textBox.Text))
            {
                return(true);
            }

            if (!double.TryParse(textBox.Text, NumberStyles.Number, StreamDeckConstants.DoubleCultureInfo, out var result))
            {
                MessageBox.Show("Please enter valid number.", "Invalid number.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox.SelectAll();
                return(false);
            }

            return(true);
        }
コード例 #6
0
 private void TextBox_SelectAllOnFocus(object sender, RoutedEventArgs e)
 {
     System.Windows.Controls.TextBox textbox = (System.Windows.Controls.TextBox)e.Source;
     textbox.SelectAll();
 }
コード例 #7
0
 private void LocationState_GotKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e)
 {
     System.Windows.Controls.TextBox tb = (System.Windows.Controls.TextBox)sender;
     Dispatcher.BeginInvoke(new Action(() => tb.SelectAll()));
 }