當前位置: 首頁>>代碼示例>>C#>>正文


C# TextBox.Clear方法代碼示例

本文整理匯總了C#中System.Windows.Controls.TextBox.Clear方法的典型用法代碼示例。如果您正苦於以下問題:C# TextBox.Clear方法的具體用法?C# TextBox.Clear怎麽用?C# TextBox.Clear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Controls.TextBox的用法示例。


在下文中一共展示了TextBox.Clear方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CalculateLoadScheme

        public List<Container> CalculateLoadScheme(List<Container> containers,
            ObservableCollection<Vehicle> selectedVehicles, TextBox textBox, int maxTonnage)
        {
            // BtnCalculate_click
            int tempMaxTonnage;
            var widthBetweenVehicles = 1000;
            var tempPoint = new Point3D(0, 0, 0);
            textBox.Clear();
            textBox.AppendText("Протокол расчета схемы загрузки:\n");
            var tempList = RotateContainers(containers);

            foreach (var vehicle in selectedVehicles)
            {
                LocateContainers locateContainers = new LocateContainers(vehicle);

                tempMaxTonnage = maxTonnage == 0 ? vehicle.Tonnage : maxTonnage;
                tempList = locateContainers.DownloadContainers(tempList, tempMaxTonnage);
                SetFirstPoint(tempPoint,vehicle);
                tempPoint.Y = tempPoint.Y + widthBetweenVehicles + vehicle.Width;// TODO tempPoint.Z = tempPoint.Z + widthBetweenVehicles + vehicle.Width;
                PutCargoInfoInTextBox(vehicle, textBox);
                CheckOverweight(vehicle, textBox, tempMaxTonnage);
                VehicleAxisMass vehicleAxisMass = new VehicleAxisMass(vehicle, vehicle.Mass);
                PutVehAxisMassInfoInTextBox(vehicleAxisMass.AxisMassCalculate(), textBox);
            }
            PutWasteContainersInfoInTextBox(tempList, textBox);
            CheckErrors(tempList, textBox, selectedVehicles, containers);

            return tempList;
        }
開發者ID:RadSt,項目名稱:WPF-App-For-Ref,代碼行數:29,代碼來源:Calculation.cs

示例2: Limpiar

 public static void Limpiar(TextBox t1, TextBox t2 = null, TextBox t3 = null)
 {
     t1.Clear();
     if (t2 != null)
         t2.Clear();
     if (t3 != null)
         t3.Clear();
     t1.Focus();
 }
開發者ID:amarodev,項目名稱:PantallasCC,代碼行數:9,代碼來源:Utilidades.cs

示例3: bin

 //DEC TO BIN
 private void bin(int dec, TextBox text)
 {
     text.Clear();
     for(int i=15;i>=0;i--)
     {
         if (i == 7) text.Text += " ";
         text.Text += Convert.ToString((dec >> i) % 2);
     }
 }
開發者ID:pgalias,項目名稱:Microprocessor-simulator,代碼行數:10,代碼來源:MainWindow.xaml.cs

示例4: checkNumBox

        void checkNumBox(TextBox box)
        {
            int convertedText = 0;
            if (!int.TryParse(box.Text, out convertedText))
            {
                box.Clear();
            }

        }
開發者ID:Alarih,項目名稱:InfBezopasnostLaboratornieRaboti,代碼行數:9,代碼來源:NodTab.xaml.cs

示例5: ButtonCode

        public void ButtonCode(int GBATotal, int NDSTotal, bool GBA, bool NDS, TextBox ButtonInput, TextBox ButtonOutput, TextBox NDSTst, TextBox GBATst)
        {
            //NOT_GBA and NOT_NDS will hold the 
            //16-bit values of NOT_GBATotal and NOT_NDSTotal
            string D2 = "D2000000 00000000";
            ushort NOT_GBA = (ushort)~GBATotal;
            ushort NOT_NDS = (ushort)~NDSTotal; 

            if (GBATotal != 0)
                GBA = true;
            if (NDSTotal != 0)
                NDS = true;

            if (GBA == true)
            {
                ButtonOutput.Text = "94000130 " + NOT_GBA.ToString("X") + "0000\n" + ButtonInput.Text + '\n' + D2;
                GBATst.Text = "GBA tst Value: 0x" + GBATotal.ToString("X4");
            }
            else GBATst.Clear();

            if (NDS == true)
            {
                ButtonOutput.Text = "927FFFA8 " + NOT_NDS.ToString("X") + "0000\n" + ButtonInput.Text + '\n' + D2;
                NDSTst.Text = "NDS tst Value: 0x" + NDSTotal.ToString("X4");
            }
            else NDSTst.Clear();

            if (GBA == true && NDS == true)
            {
                ButtonOutput.Text = "927FFFA8 " + NOT_NDS.ToString("X") + "0000\n94000130 " +
                             NOT_GBA.ToString("X") + "0000\n" + ButtonInput.Text + '\n' + D2;
            }
            else if (GBA == false && NDS == false)
            {
                ButtonOutput.Clear();
                GBATst.Clear();
                NDSTst.Clear();
            }
        }
開發者ID:vinnydiehl,項目名稱:NDS-Toolkit-.NET,代碼行數:39,代碼來源:ButtonGenerator.cs

示例6: checkTextBox

        void checkTextBox(TextBox box)
        {
            if (box.Text.Intersect(forbiddenChars).Any())
            {
                box.Clear();
            }

            if (box.Text.Intersect(smallChars).Any())
            {
                box.Text = box.Text.ToUpper();
                box.SelectionStart = box.Text.Length;
                box.SelectionLength = 0;
            }
        }
開發者ID:Alarih,項目名稱:InfBezopasnostLaboratornieRaboti,代碼行數:14,代碼來源:LabTab2.xaml.cs

示例7: handleTextChange

        //checks whether textbox content > 255 when 3 characters have been entered.
        //clears if > 255, switches to next textbox otherwise
        private void handleTextChange(TextBox currentBox, TextBox rightNeighborBox)
        {
            if (currentBox.Text.Length == 3)
            {
                try
                {
                    Convert.ToByte(currentBox.Text);

                }
                catch (Exception exception) when (exception is FormatException || exception is OverflowException)
                {
                    currentBox.Clear();
                    currentBox.Focus();
                    SystemSounds.Beep.Play();
                    MessageBox.Show(errorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }
                if (currentBox.CaretIndex != 2 && currentBox != fourthBox)
                {
                    rightNeighborBox.CaretIndex = rightNeighborBox.Text.Length;
                    rightNeighborBox.SelectAll();
                    rightNeighborBox.Focus();
                }
            }
        }
開發者ID:RuvenSalamon,項目名稱:IP-MaskedTextBox,代碼行數:27,代碼來源:UserControl1.xaml.cs

示例8: ApplicationCanvas

        public ApplicationCanvas()
        {
            r.Fill = Brushes.LightGray;
            r.AttachTo(this);
            r.MoveTo(4, 4);
            this.SizeChanged += (s, e) => r.SizeTo(this.Width - 8.0, this.Height - 8.0);

            var label1 = new TextBlock
            {
                Text = "Enter a list of names separated by commas",
            }.AttachTo(this).MoveTo(8, 8);

            var users = new TextBox
            {
                AcceptsReturn = true,
                TextWrapping = System.Windows.TextWrapping.Wrap,
                Width = 500,
                Height = 50,
                Text = "_martin, mike, mac, ken, neo, zen, jay, morpheous, trinity, Agent Smith, _psycho",
            }.AttachTo(this).MoveTo(8, 8 + 32);



            var label2 = new TextBlock
            {
                Text = "Enter a partial name to be found from the list above.",
            }.AttachTo(this).MoveTo(8, 8 + 32 + 50 + 8);

            var filter = new TextBox
            {
                Width = 500,
                Text = "psy",
            }.AttachTo(this).MoveTo(8, 8 + 32 + 50 + 8 + 16);

            var label3 = new TextBlock
            {
                Text = "Enter a partial name to make the entry special",
            }.AttachTo(this).MoveTo(8, 8 + 32 + 50 + 8 + 58);

            var filter2 = new TextBox
            {
                Width = 500,
                Text = "a",
            }.AttachTo(this).MoveTo(8, 8 + 32 + 50 + 8 + 16 + 58);



            var label4 = new TextBlock
            {
                Text = "Results",
            }.AttachTo(this).MoveTo(8, 8 + 32 + 50 + 8 + 58 + 58);

            var result = new TextBox
            {
                AcceptsReturn = true,
                TextWrapping = System.Windows.TextWrapping.Wrap,

                Background = Brushes.Transparent,
                BorderThickness = new Thickness(0),

                Width = 500,
                Height = 50,
                Text = "?",
                TextAlignment = System.Windows.TextAlignment.Right,
                IsReadOnly = true,
            }.AttachTo(this).MoveTo(8, 8 + 32 + 50 + 8 + 16 + 58 + 58);

            Action Update =
                delegate
                {
                    var user_filter = filter.Text.Trim().ToLower();
                    var user_filter2 = filter2.Text.Trim().ToLower();

                    result.Clear();

                    var __users = users.Text.Split(',');


                    var query = from i in __users
                                where i.ToLower().Contains(user_filter)
                                let name = i.Trim()
                                let isspecial = i.ToLower().Contains(user_filter2)
                                orderby isspecial ascending, name.Length descending, name
                                select new { isspecial, length = name.Length, name };

                    foreach (var v in query)
                    {
                        var m = "match: " + v;

                        if (v.isspecial)
                            m = m.ToUpper();

                        result.AppendText(m + Environment.NewLine);
                    }
                };

            Update();

            users.TextChanged += delegate { Update(); };
            filter.TextChanged += delegate { Update(); };
//.........這裏部分代碼省略.........
開發者ID:exaphaser,項目名稱:JSC-Cross-Compiler,代碼行數:101,代碼來源:ApplicationCanvas.cs

示例9: checkLanguage

        bool checkLanguage(TextBox box)
        {
            bool result = true;

            if (language == Alphabet.English)
            {
                if (box.Text.Intersect(Cezar.ALPHABET_RU).Any())
                {
                    box.Clear();
                    result = false;
                }
            }

            if (language == Alphabet.Russian)
            {
                if (box.Text.Intersect(Cezar.ALPHABET_EN).Any())
                {
                    box.Clear();
                    result = false;
                }
            }

            return result;
        }
開發者ID:Alarih,項目名稱:InfBezopasnostLaboratornieRaboti,代碼行數:24,代碼來源:KP_Sym.xaml.cs

示例10: printToBox

 void printToBox(TextBox box, int[] array)
 {
     box.Clear();
     foreach (byte num in array)
     {
         //if (num == 0) continue;
         box.Text += num + " ";
     }
 }
開發者ID:Alarih,項目名稱:InfBezopasnostLaboratornieRaboti,代碼行數:9,代碼來源:Lab1.xaml.cs

示例11: auxRestAfterDamage

 //aux function for a damage timer, its sending workers to rest
 private void auxRestAfterDamage(TextBox text)
 {
     //during breakdown
     int freePositions = Convert.ToInt32(tbNumber.Text) + 1;
     load.amountWorkers = load.amountWorkers - 1;
     text.IsEnabled = false;
     auxFill();
     tbNumber.Text = Convert.ToString(freePositions);
     text.Clear();
 }
開發者ID:pgalias,項目名稱:Production-line-simulator,代碼行數:11,代碼來源:MainWindow.xaml.cs

示例12: ConstructObjects

        private void ConstructObjects()
        {
            var lbStation = new Label();
            lbStation.Content = "選擇站別 ( * ) :";

            var bStation = new Border();
            bStation.Width = 300;
            bStation.Height = 40;
            bStation.Background = Brushes.White;
            bStation.BorderBrush = Brushes.White;
            bStation.BorderThickness = new Thickness(5);

            var cbstation = new ComboBox();
            cbstation.Items.Add(StationName.gStationA);
            cbstation.Items.Add(StationName.gStationB);
            cbstation.Items.Add(StationName.gStationC);
            //cbstation.Items.Add(StationName.gStationD);
            cbstation.Items.Add(StationName.gStationE);
            cbstation.Items.Add(StationName.gStationF);
            cbstation.Items.Add(StationName.gStationG);

            bStation.Child = cbstation;
            cbstation.SelectionChanged += cbstation_SelectionChanged;

            var spName = new StackPanel();
            spName.HorizontalAlignment = HorizontalAlignment.Left;
            var lbUsername = new Label();
            lbUsername.Content = "操作人員  ( * ) :";
            var txtboxUsername = new TextBox();
            txtboxUsername.Height = 30;
            txtboxUsername.Width = 150;
            txtboxUsername.KeyUp += txtboxUsername_KeyUp;
            spName.Children.Add(lbUsername);
            spName.Children.Add(txtboxUsername);

            var lbLogin = new Label();
            lbLogin.Content = SigknowDBServer.gServer;

            var buttonLogin = new Button();
            buttonLogin.Content = "登入";
            buttonLogin.Click += buttonLogin_Click;
            buttonLogin.Height = 30;
            buttonLogin.Width = 50;

            var spServer = new StackPanel();
            spServer.HorizontalAlignment = HorizontalAlignment.Left;
            var lbServer = new Label();
            lbServer.Content = "資料庫網址  ( * ) :";
            var txtboxServer = new TextBox();
            txtboxServer.Height = 30;
            txtboxServer.Width = 150;
            txtboxServer.KeyUp += txtboxServer_KeyUp;
            var buttonServer = new Button();
            buttonServer.Content = "設定";
            buttonServer.Click += buttonServer_Click;
            buttonServer.Height = 30;
            buttonServer.Width = 50;
            Utils.changeTextboxLang2Eng(txtboxServer);
            var lbReport = new Label();
            lbReport.Content = "";
            spServer.Children.Add(lbServer);
            spServer.Children.Add(txtboxServer);

            var buttonReport = new Button();
            buttonReport.Content = "匯出資料";
            buttonReport.Click += buttonReport_Click;
            buttonReport.Height = 30;
            buttonReport.Width = 100;

            StackPanel spMainBody = new StackPanel();
            spMainBody.HorizontalAlignment = HorizontalAlignment.Left;

            spMainBody.Children.Add(spServer);
            spMainBody.Children.Add(buttonServer);

            spMainBody.Children.Add(lbStation);
            spMainBody.Children.Add(bStation);
            spMainBody.Children.Add(spName);
            spMainBody.Children.Add(lbLogin);
            spMainBody.Children.Add(buttonLogin);

            spMainBody.Children.Add(lbReport);
            spMainBody.Children.Add(buttonReport);

            txtboxServer.Clear();
            txtboxServer.Focus();

            Content = spMainBody;
        }
開發者ID:taiyuanw,項目名稱:sigknowShopFloor,代碼行數:89,代碼來源:MainWindow.xaml.cs

示例13: Parse

 private decimal Parse(TextBox txt)
 {
     decimal var;
     try
     {
         if (!String.IsNullOrWhiteSpace(txt.Text))
         {
             // Try to parse param if it's not null
             var = decimal.Parse(txt.Text);
         }
         else
         {
             var = 0m;
         }
     }
     catch
     {
         // Clear and focus on error location. Prompt user as to where the error occurred using the ToolTip
         txt.Clear();
         txt.Focus();
         throw new Exception("Error! Value of " + txt.ToolTip.ToString() + " required as a decimal");
     }
     return var;
 }
開發者ID:JackHillman,項目名稱:4C-B-Assignment,代碼行數:24,代碼來源:Sale.cs

示例14: Clean

 public static void Clean(TextBox textbox)
 {
     textbox.Clear();
 }
開發者ID:estebanl,項目名稱:Manufacture,代碼行數:4,代碼來源:ControlValidation.cs

示例15: rest

 //function sending workers to rest
 private void rest(TextBox text)
 {
     int freePositions = Convert.ToInt32(tbNumber.Text) + 1;
     if (text.IsEnabled == true)
     {
         load.amountWorkers = load.amountWorkers - 1;
         text.IsEnabled = false;
         auxFill();
         tbNumber.Text = Convert.ToString(freePositions);
         text.Clear();
     }
     else MessageBox.Show("This position is not filled!");
 }
開發者ID:pgalias,項目名稱:Production-line-simulator,代碼行數:14,代碼來源:MainWindow.xaml.cs


注:本文中的System.Windows.Controls.TextBox.Clear方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。