当前位置: 首页>>代码示例>>C#>>正文


C# Controls.TextBox类代码示例

本文整理汇总了C#中System.Windows.Controls.TextBox的典型用法代码示例。如果您正苦于以下问题:C# TextBox类的具体用法?C# TextBox怎么用?C# TextBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TextBox类属于System.Windows.Controls命名空间,在下文中一共展示了TextBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: for_MouseDown

 private void for_MouseDown(object sender, MouseButtonEventArgs e)
 {
     SolidColorBrush[] brushes = new SolidColorBrush[]
                                 {   Brushes.Green, Brushes.BurlyWood,Brushes.CadetBlue,
                                     Brushes.Gray,Brushes.Chartreuse,Brushes.Chocolate,
                                     Brushes.AliceBlue,Brushes.Coral,Brushes.CornflowerBlue,
                                     Brushes.AntiqueWhite,Brushes.Cornsilk,Brushes.Crimson,
                                     Brushes.Aqua,Brushes.Cyan,Brushes.DarkBlue,Brushes.DarkCyan,
                                     Brushes.Aquamarine,Brushes.DarkGoldenrod,Brushes.DarkGray,
                                     Brushes.Azure,Brushes.DarkGreen,Brushes.DarkKhaki,
                                     Brushes.Beige,Brushes.DarkMagenta,Brushes.DarkOliveGreen,
                                     Brushes.Bisque,Brushes.DarkOrange,Brushes.DarkOrchid,
                                     Brushes.Black,Brushes.DarkRed,Brushes.DarkSalmon,
                                     Brushes.BlanchedAlmond,Brushes.DarkSeaGreen,Brushes.DarkSlateBlue,
                                     Brushes.Blue,Brushes.DarkSlateGray,Brushes.DarkTurquoise,
                                     Brushes.BlueViolet,Brushes.Brown,Brushes.DarkViolet
                                 };
     TextBox b = new TextBox() { Text = "Label " + contC };
     b.Name = "s" + contador;
     b.Background = brushes[new Random().Next(brushes.Length)];
     b.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
     b.VerticalAlignment = System.Windows.VerticalAlignment.Top;
     b.PreviewMouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.TextBox_PreviewMouseLeftButtonDown);
     b.PreviewMouseDown += new System.Windows.Input.MouseButtonEventHandler(this.TextBox_PreviewDown);
     this.workSpace.Children.Add(b);
     b.Margin = new Thickness(0, 0, 0, 0);
     contC++;
 }
开发者ID:RobertCalbul,项目名称:Hilos,代码行数:28,代码来源:MainWindow.xaml.cs

示例2: IsNonEmpty

        internal static bool IsNonEmpty(TextBox input)
        {
            bool result = false;
            try
            {
                if (false == string.IsNullOrEmpty(input.Text))
                {
                    SetToDefaultStyle(input);

                    result = true;
                }
                else
                {
                    Style textBoxErrorStyle;
                    FrameworkElement frameworkElement;
                    frameworkElement = new FrameworkElement();
                    textBoxErrorStyle = (Style)frameworkElement.TryFindResource("textBoxEmptyErrorStyle");
                    input.Style = textBoxErrorStyle;
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }

            return result;
        }
开发者ID:ultrasonicsoft,项目名称:G1,代码行数:27,代码来源:Helper.cs

示例3: OnlyNumbersAndCommas

 public static void OnlyNumbersAndCommas(KeyEventArgs e, TextBox tb)
 {
     if (e.Key != Key.Decimal && e.Key != Key.OemComma && (e.Key < Key.D0 || e.Key > Key.D9) && (e.Key < Key.NumPad0 || e.Key > Key.NumPad9))
     {
         e.Handled = true;
     }
 }
开发者ID:pavlove,项目名称:DailyClient,代码行数:7,代码来源:Validation.cs

示例4: KinectDance

        public KinectDance(double layoutHeight, double layoutWidth, List<TextBlock> menus, Style mouseOverStyle, Border menuBorder,TextBox debugBox = null)
        {
            _layoutHeight = layoutHeight;
            _layoutWidth = layoutWidth;
            _debugBox = debugBox;
            _menus = menus;
            _menuBorder = menuBorder;
            _mouseOverStyle = mouseOverStyle;

            _kinect = KinectSensor.KinectSensors.FirstOrDefault();

            if (_kinect == null) return;
            //_kinect.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated;
            _kinect.Start();

            _kinect.ColorStream.Enable();
            _kinect.SkeletonStream.Enable(new TransformSmoothParameters
                {
                    Smoothing = 0.7f,
                    Correction = 0.3f,
                    Prediction = 0.4f,
                    JitterRadius = 0.5f,
                    MaxDeviationRadius = 0.5f
                });

            _kinect.SkeletonFrameReady += kinect_SkeletonFrameReady;
        }
开发者ID:rudylee,项目名称:WpfApp,代码行数:27,代码来源:KinectDance.cs

示例5: GenereateFields

        public static void GenereateFields()
        {
            // Get the Grid from the MainWindow
            Grid AuthenticationGrid = ((MainWindow)System.Windows.Application.Current.MainWindow).AuthenticationGrid;

            // Build a list of Digest Auth Fields
            List<string> fields = new List<string>();
            fields.Add("Username");
            fields.Add("Password");

            for (int i = 0; i < fields.Count; i++)
            {
                // Add a row to the AuthGrid
                RowDefinition rowDefinition = new RowDefinition();
                rowDefinition.Height = GridLength.Auto;
                AuthenticationGrid.RowDefinitions.Add(rowDefinition);

                // Add a Label
                Label label = new Label();
                label.SetValue(Grid.RowProperty, i + 1);
                label.SetValue(Grid.ColumnProperty, 0);
                label.Name = "AuthenticationKey" + i;
                label.Content = fields[i] + ":";
                AuthenticationGrid.Children.Add(label);

                // Add a textbox
                TextBox textBox = new TextBox();
                textBox.SetValue(Grid.RowProperty, i + 1);
                textBox.SetValue(Grid.ColumnProperty, 1);
                textBox.Name = "AuthenticationValue" + i;
                AuthenticationGrid.Children.Add(textBox);
            }
        }
开发者ID:MattGong,项目名称:RESTful,代码行数:33,代码来源:BasicAuth.cs

示例6: KinectControl

        public KinectControl(HoverButton kinectButton, double layoutHeight, double layoutWidth, List<Button> buttons, TextBox debugBox = null)
        {
            _kinectButton = kinectButton;
            _layoutHeight = layoutHeight;
            _layoutWidth = layoutWidth;
            _buttons = buttons;
            _debugBox = debugBox;

            _kinect = KinectSensor.KinectSensors.FirstOrDefault();

            if (_kinect != null)
            {
                _kinect.Start();

                _kinect.ColorStream.Enable();
                _kinect.SkeletonStream.Enable(new TransformSmoothParameters
                    {
                        Smoothing = 0.7f,
                        Correction = 0.1f,
                        Prediction = 0.1f,
                        JitterRadius = 0.05f,
                        MaxDeviationRadius = 0.05f
                    });

                _kinect.SkeletonFrameReady += kinect_SkeletonFrameReady;
            }

            _activeRecognizer = CreateRecognizer();
            _kinectButton.Click += KinectButton_Click;
        }
开发者ID:rudylee,项目名称:WpfApp,代码行数:30,代码来源:KinectControl.cs

示例7: toInt

 private static int toInt(TextBox tb)
 {
     if (string.IsNullOrEmpty(tb.Text))
         return 0;
     else
         return Convert.ToInt32(tb.Text);
 }
开发者ID:Hades32,项目名称:Better-WP7-DateTime-Picker,代码行数:7,代码来源:PickerPage.xaml.cs

示例8: StateChangeAdorner

 public StateChangeAdorner(TextBox adornedElement, StateChange change)
     : base(adornedElement)
 {
     this.text.FontSize = adornedElement.FontSize * 0.80;
     this.text.Text = change.Variable + " = " + change.Value;
     this.border.Child = this.text;
 }
开发者ID:ermau,项目名称:Instant,代码行数:7,代码来源:StateChangeAdorner.cs

示例9: BasicsWindow

        public BasicsWindow()
        {
            Window basics = new Window
            {
                Title = "Code Basics",
                Height = 400,
                Width = 400,
                FontSize = 20,
            };

            StackPanel sp = new StackPanel();
            basics.Content = sp;

            TextBlock title = new TextBlock
            {
                Text = "Code Basics",
                FontSize = 24,
                TextAlignment = TextAlignment.Center,
            };
            sp.Children.Add(title);

            txtName = new TextBox();
            sp.Children.Add(txtName);
            txtName.Margin = new Thickness(10);

            Button btnSend = new Button
            {
                Content = "Send",
            };
            sp.Children.Add(btnSend);
            btnSend.Margin = new Thickness(10);
            btnSend.Click += BtnSend_Click;

            basics.Show();
        }
开发者ID:rnmisrahi,项目名称:JB,代码行数:35,代码来源:BasicsWindow.cs

示例10: utiliseAlphabet

        /// <summary>
        /// Premet de savoir si l'utilisateur utilise a-z ou A-Z 
        /// </summary>
        /// <param name="champ">champ à valider</param>
        /// <returns>Retourne vrai si le champ contient des lettres uniquement</returns>
        private bool utiliseAlphabet(TextBox champ)
        {
            int nbTirets = 0;
            for (int car = 0; car < champ.Text.Length; car++)
            {
                if (champ.Text[car] != '-')
                {
                    if (!((champ.Text[car] >= 97 && champ.Text[car] <= 122) || (champ.Text[car] >= 65 && champ.Text[car] <= 90)))
                    {
                        return false;
                    }
                }
                else
                {
                    nbTirets++;

                    // Si l'utilisateur utilise plus de 2 tirets, le champ n'est pas valide
                    if (nbTirets > 1)
                    {
                        return false;
                    }
                }
            }
            return true;
        }
开发者ID:devilsouley,项目名称:Harmonition,代码行数:30,代码来源:CreationDeCompte.xaml.cs

示例11: RecalculateVisibility

        private void RecalculateVisibility(object oldValue, object newValue)
        {
            if(AutoChild)
            {
                // when datacontext change is fired but its not loaded, it's quite possible that some Common.Routes are not working yet
                if (newValue == null/* || !IsLoaded*/) 
                    Child = null;
                else
                {
                    EntitySettings es = Navigator.Manager.EntitySettings.TryGetC(newValue.GetType());
                    if (es == null)
                        Child = new TextBox
                        {
                            Text = "No EntitySettings for {0}".FormatWith(newValue.GetType()),
                            Foreground = Brushes.Red,
                            FontWeight = FontWeights.Bold
                        };
                    else
                        Child = es.CreateView((ModifiableEntity)newValue, Common.GetPropertyRoute(this)); 
                }
            }
            if (Child != null)
            {
                if (newValue == null)
                    Child.Visibility = Visibility.Hidden;
                else
                    Child.Visibility = Visibility.Visible;

                if (oldValue != null && newValue != null)
                    Child.BeginAnimation(UIElement.OpacityProperty, animation);
            }
        }
开发者ID:rondoo,项目名称:framework,代码行数:32,代码来源:DataBorder.cs

示例12: AutoCompleteTextBox

        public AutoCompleteTextBox()
        {
            controls = new VisualCollection(this);
            InitializeComponent();

            searchThreshold = 2;        // default threshold to 2 char

            // set up the key press timer
            keypressTimer = new System.Timers.Timer();
            keypressTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEvent);

            // set up the text box and the combo box
            comboBox = new ComboBox();
            comboBox.IsSynchronizedWithCurrentItem = true;
            comboBox.IsTabStop = false;
            comboBox.SelectionChanged += new SelectionChangedEventHandler(comboBox_SelectionChanged);

            textBox = new TextBox();
            textBox.TextChanged += new TextChangedEventHandler(textBox_TextChanged);
            textBox.VerticalContentAlignment = VerticalAlignment.Center;

            controls.Add(comboBox);
            controls.Add(textBox);

        }
开发者ID:TrinityCore-Manager,项目名称:TrinityCore-Manager-v3,代码行数:25,代码来源:AutoCompleteTextBox.xaml.cs

示例13: Use_Zip_Code

        private void Use_Zip_Code(object sender, System.Windows.RoutedEventArgs e)
        {
            TextBox textBox = new TextBox();
            // restrict input to digits:
            InputScope inputScope = new InputScope();
            InputScopeName inputScopeName = new InputScopeName();
            inputScopeName.NameValue = InputScopeNameValue.Digits;
            inputScope.Names.Add(inputScopeName);
            textBox.InputScope = inputScope;

            CustomMessageBox messageBox = new CustomMessageBox()
            {
                Message = "Enter your US zip code:",
                LeftButtonContent = "okay",
                RightButtonContent = "cancel",
                Content = textBox
            };
            messageBox.Loaded += (a, b) =>
            {
                textBox.Focus();
            };
            messageBox.Show();
            messageBox.Dismissed += (s, args) =>
            {
                if (args.Result == CustomMessageBoxResult.LeftButton)
                {
                    if (textBox.Text.Length >= 5)
                    {
                        geocodeUsingString(textBox.Text);
                    }
                }
            };
        }
开发者ID:nate-parrott,项目名称:weatherping,代码行数:33,代码来源:Location.xaml.cs

示例14: IsValidCurrency

        internal static bool IsValidCurrency(TextBox input)
        {
            bool result = false;
            try
            {
                if (input.Text == "0.00")
                {
                    SetToDefaultStyle(input);
                    return true;
                }

                if (false == string.IsNullOrEmpty(input.Text) && Regex.IsMatch(input.Text, @"^[0-9]*(?:\.[0-9]*)?$"))
                {
                    SetToDefaultStyle(input);

                    result = true;
                }
                else
                {
                    Style textBoxErrorStyle;
                    FrameworkElement frameworkElement;
                    frameworkElement = new FrameworkElement();
                    textBoxErrorStyle = (Style)frameworkElement.TryFindResource("textBoxCurrencyErrorStyle");
                    input.Style = textBoxErrorStyle;
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }

            return result;
        }
开发者ID:ultrasonicsoft,项目名称:G1,代码行数:33,代码来源:Helper.cs

示例15: IsNumberOnly

        internal static bool IsNumberOnly(TextBox input)
        {
            bool result = false;
            try
            {
                if (Regex.IsMatch(input.Text, @"^\d+$"))
                {
                    SetToDefaultStyle(input);
                    result = true;
                }
                else
                {
                    Style textBoxErrorStyle;
                    FrameworkElement frameworkElement;
                    frameworkElement = new FrameworkElement();
                    //textBoxNormalStyle = (Style)frameworkElement.TryFindResource("textBoxNormalStyle");
                    textBoxErrorStyle = (Style)frameworkElement.TryFindResource("textBoxNumericErrorStyle");
                    input.Style = textBoxErrorStyle;
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }

            return result;
        }
开发者ID:ultrasonicsoft,项目名称:G1,代码行数:27,代码来源:Helper.cs


注:本文中的System.Windows.Controls.TextBox类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。