• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Controls.TextBox类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: ShowInfoAppend

        public static void ShowInfoAppend(TextBox showWin, System.String strInfo)
        {
            System.String strShowInfo = System.String.Empty;

            strShowInfo = strInfo;
            UnitFunClass.ShowMsgInInfoWindow(showWin, LogLevelEnum.LOG_INFO, strShowInfo);
        }
开发者ID:pplong2012,项目名称:DBManagerMDI,代码行数:7,代码来源:UnitFunClass.cs


示例17: lstAdapters_SelectionChanged

        private void lstAdapters_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            lstAdapterItem selItem = ((lstAdapterItem)lstAdapters.SelectedItem);
            TextBox dnsBox = new TextBox() { Text = selItem.PrimaryDNS };

            TiltEffect.SetIsTiltEnabled(dnsBox, true);

            CustomMessageBox messageBox = new CustomMessageBox()
            {
                Caption = "Edit DNS for " + selItem.Name,
                Message = "Primary DNS Server:",
                Content = dnsBox,
                LeftButtonContent = "save",
                RightButtonContent = "cancel",
                IsFullScreen = false
            };

            messageBox.Dismissed += (s1, e1) =>
            {
                if (e1.Result == CustomMessageBoxResult.LeftButton)
                {
                    Registry.SetMultiStringValue(selItem.KeyRoot, selItem.KeyPath, "DNS", new string[] { dnsBox.Text });
                    //TODO: Clear the list first
                    refreshAdapters();
                }
                //TODO: Fix this
                //lstAdapters.SelectedIndex = -1;
            };

            messageBox.Show();
        }
开发者ID:Digiex,项目名称:DNSChangerWP7,代码行数:31,代码来源:MainPage.xaml.cs


示例18: AddCredit_Click

        private void AddCredit_Click(object sender, RoutedEventArgs e)
        {
            Credits.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });

            WrapPanel wp = new WrapPanel();
            Grid.SetRow(wp, Credits.RowDefinitions.Count - 1);
            Credits.Children.Add(wp);

            TextBox nameBox = new TextBox();
            nameBox.Name = creditname;
            nameBox.MinWidth = 170;
            wp.Children.Add(nameBox);

            Button saveButton = new Button();
            saveButton.Name = savebutton;
            saveButton.Height = 20;
            saveButton.Width = 20;
            saveButton.Margin = new Thickness(10, 0, 0, 0);
            saveButton.Click += new RoutedEventHandler(saveButton_Click);
            Image okImage = new Image();
            okImage.Source = Helpers.BitmapSourceFromBitmap(Exp1.Properties.Resources.ok);
            saveButton.Content = okImage;
            wp.Children.Add(saveButton);

            Button cancelButton = new Button();
            cancelButton.Name = cancelbutton;
            cancelButton.Height = 20;
            cancelButton.Width = 20;
            cancelButton.Margin = new Thickness(10, 0, 0, 0);
            cancelButton.Click += new RoutedEventHandler(cancelButton_Click);
            Image cancelImage = new Image();
            cancelImage.Source = Helpers.BitmapSourceFromBitmap(Exp1.Properties.Resources.cancel);
            cancelButton.Content = cancelImage;
            wp.Children.Add(cancelButton);
        }
开发者ID:asdanilenk,项目名称:Exp1,代码行数:35,代码来源:MainWindow.xaml.cs


示例19: CustomerInfoSearch

        public CustomerInfoSearch(ICollectionView filteredList, TextBox textEdit)
        {
            string filterText = string.Empty;

            filteredList.Filter = delegate(object obj)
            {
                if (String.IsNullOrEmpty(filterText))
                {
                    return true;
                }
                ModelCustomer str = obj as ModelCustomer;
                if (str.UserName==null)
                {
                    return true;
                }
                if (str.UserName.ToUpper().Contains(filterText.ToUpper()))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            };
            textEdit.TextChanged += delegate
            {
                filterText = textEdit.Text;
                filteredList.Refresh();
            };
        }
开发者ID:shuvo009,项目名称:CafeteriaVernier,代码行数:30,代码来源:CustomerInfoSearch.cs


示例20: PopUpTerminal

        //for creating a new terminal
        public PopUpTerminal(Airport airport)
        {
            this.Airport = airport;

            InitializeComponent();

            this.Uid = "1000";
            this.Title = Translator.GetInstance().GetString("PopUpTerminal", this.Uid);

            this.Width = 400;

            this.Height = 200;

            this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;

            StackPanel mainPanel = new StackPanel();
            mainPanel.Margin = new Thickness(10, 10, 10, 10);

            ListBox lbTerminal = new ListBox();
            lbTerminal.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
            lbTerminal.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem");

            mainPanel.Children.Add(lbTerminal);

            // chs 28-01-12: added for name of terminal
            txtName = new TextBox();
            txtName.Background = Brushes.Transparent;
            txtName.BorderBrush = Brushes.Black;
            txtName.IsEnabled = this.Terminal == null;
            txtName.Width = 100;
            txtName.Text = this.Terminal == null ? "Terminal" : this.Terminal.Name;
            lbTerminal.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PopUpTerminal","1007"),txtName));

            // chs 11-09-11: added numericupdown for selecting number of gates
            nudGates = new ucNumericUpDown();
            nudGates.Height = 30;
            nudGates.MaxValue = 50;
            nudGates.ValueChanged+=new RoutedPropertyChangedEventHandler<decimal>(nudGates_ValueChanged);
            nudGates.MinValue = 1;

            lbTerminal.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PopUpTerminal", "1001"), nudGates));
            /*
            lbTerminal.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PopUpTerminal", "1002"), UICreator.CreateTextBlock(string.Format("{0:C}",this.Airport.getTerminalPrice()))));
            lbTerminal.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PopUpTerminal", "1003"), UICreator.CreateTextBlock(string.Format("{0:C}",this.Airport.getTerminalGatePrice()))));
            */
            lbTerminal.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PopUpTerminal", "1002"), UICreator.CreateTextBlock(new ValueCurrencyConverter().Convert(this.Airport.getTerminalPrice()).ToString())));
            lbTerminal.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PopUpTerminal", "1003"), UICreator.CreateTextBlock(new ValueCurrencyConverter().Convert(this.Airport.getTerminalGatePrice()).ToString())));

            txtDaysToCreate = UICreator.CreateTextBlock("0 days");
            lbTerminal.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PopUpTerminal", "1004"), txtDaysToCreate));

            txtTotalPrice = UICreator.CreateTextBlock(new ValueCurrencyConverter().Convert(0).ToString());//UICreator.CreateTextBlock(string.Format("{0:C}", 0));
            lbTerminal.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PopUpTerminal", "1005"), txtTotalPrice));

            mainPanel.Children.Add(createButtonsPanel());

            nudGates.Value = 1;

            this.Content = mainPanel;
        }
开发者ID:rhgtvcx,项目名称:tap-desktop,代码行数:61,代码来源:PopUpTerminal.xaml.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Controls.TextChangedEventArgs类代码示例发布时间:2022-05-26
下一篇:
C# Controls.TextBlock类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap